Sample Header Ad - 728x90

SET ANSI_NULLS at the database level versus setting it at the table level

6 votes
2 answers
7166 views
I have generated schema-only script for my sql server 2008 R2, here is part of it:- USE [master] GO /****** Object: Database [****] Script Date: 03/25/2015 12:17:09 ******/ CREATE DATABASE [****] ON PRIMARY ( NAME = N'TMS', FILENAME = N'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\****.mdf' , SIZE = 11264KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'TMS_log', FILENAME = N'L:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\****.ldf' , SIZE = 4672KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) GO ALTER DATABASE [****] SET COMPATIBILITY_LEVEL = 100 GO IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) begin EXEC [****].[dbo].[sp_fulltext_database] @action = 'enable' end GO ALTER DATABASE [****] SET ANSI_NULL_DEFAULT OFF GO ALTER DATABASE [****] SET ANSI_NULLS OFF GO ALTER DATABASE [****] SET ANSI_PADDING OFF GO ALTER DATABASE [****] SET ANSI_WARNINGS OFF GO ALTER DATABASE [****] SET ARITHABORT OFF GO ALTER DATABASE [****] SET AUTO_CLOSE OFF GO ALTER DATABASE [****] SET AUTO_CREATE_STATISTICS ON GO ALTER DATABASE [****] SET AUTO_SHRINK OFF GO ALTER DATABASE [****] SET AUTO_UPDATE_STATISTICS ON GO ALTER DATABASE [****] SET CURSOR_CLOSE_ON_COMMIT OFF GO ALTER DATABASE [****] SET CURSOR_DEFAULT GLOBAL GO ALTER DATABASE [****] SET CONCAT_NULL_YIELDS_NULL OFF GO ALTER DATABASE [****] SET NUMERIC_ROUNDABORT OFF GO ALTER DATABASE [****] SET QUOTED_IDENTIFIER OFF GO ALTER DATABASE [****] SET RECURSIVE_TRIGGERS OFF GO ALTER DATABASE [****] SET DISABLE_BROKER GO ALTER DATABASE [****] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GO ALTER DATABASE [****] SET DATE_CORRELATION_OPTIMIZATION OFF GO ALTER DATABASE [****] SET TRUSTWORTHY OFF GO ALTER DATABASE [****] SET ALLOW_SNAPSHOT_ISOLATION OFF GO ALTER DATABASE [****] SET PARAMETERIZATION SIMPLE GO ALTER DATABASE [****] SET READ_COMMITTED_SNAPSHOT OFF GO ALTER DATABASE [****] SET HONOR_BROKER_PRIORITY OFF GO ALTER DATABASE [****] SET READ_WRITE GO ALTER DATABASE [****] SET RECOVERY FULL GO ALTER DATABASE [****] SET MULTI_USER GO ALTER DATABASE [****] SET PAGE_VERIFY CHECKSUM GO ALTER DATABASE [****] SET DB_CHAINING OFF GO USE [****] GO /****** Object: User [AD-ITSERVICES\TMSDB.user] Script Date: 03/25/2015 12:17:09 ******/ CREATE USER [AD-ITSERVICES\test.user] FOR LOGIN [****\test.user] WITH DEFAULT_SCHEMA=[dbo] GO /****** Object: Table [dbo].[TechnologyTypes] Script Date: 03/25/2015 12:17:12 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[TechnologyTypes]( [AssetTypeID] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NOT NULL, [IncludedInSearch] [bit] NULL, CONSTRAINT [PK_AssetType] PRIMARY KEY CLUSTERED ( [AssetTypeID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], CONSTRAINT [IX_AssetType] UNIQUE NONCLUSTERED ( [Name] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[TechnologyStatus] Script Date: 03/25/2015 12:17:12 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON now i am confused on why i go this sentence :- ALTER DATABASE [****] SET ANSI_NULL_DEFAULT OFF GO ALTER DATABASE [****] SET ANSI_NULLS OFF but when creating any sql table i will get :- SET ANSI_NULLS ON so what is the final result; is ANSI_NULLS will be equal to off or on ? from my understanding the "SET ANSI_NULLS" will be OFF at the database level, unless i set it ON at the table level ? is this correct ? any why i got the ANSI_NULLs set to off at the database level ?
Asked by john Gu (1 rep)
Jul 6, 2015, 10:42 AM
Last activity: May 27, 2024, 06:16 PM