Scott
Scott

Reputation: 2183

Sql Server Management Studio - Programmatically Creating Scripts based on DAL; Why use SET ANSI_NULLS ON before each table

I'm looking to generate the SQL scripts for table creation programmatically based on class definitions in my DAL similar to SQL Server Management Studio.

So, when I right click on a table in MS SMS, and tell it to script table as > Create to > new query window, it generates some very understandable code. However, I'm not sure why they generate a few of the following lines:

I have looked these statements in the product documentation, and understand what they are for, but am not sure why they are generated around each table declaration.

Upvotes: 0

Views: 347

Answers (1)

gbn
gbn

Reputation: 432361

These settings are stored with the table or code definition. If you set these in a stored proc, then they are ignored at runtime.

So, if you script the table, you need to script the settings too. Especially if you have computed columns etc too.

Upvotes: 1

Related Questions