Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Script Table as' in SSMS Not Preserving Collation

Tags:

sql

sql-server

Is there a way to get the 'Script Table as' > 'CREATE To' option for tables in SQL Server Management Studio to preserve the collation types set for each column?

I know it's possible to specify collation types for columns when creating tables so I find it odd that these settings aren't present in the script output by SSMS.

like image 923
weenoid Avatar asked Aug 23 '13 08:08

weenoid


People also ask

What does it mean by the As in the default collation SQL_Latin1_General_CP1_CI_AS?

The server collation is specified during SQL Server installation. The default server-level collation is based upon the locale of the operating system. For example, the default collation for systems using US English (en-US) is SQL_Latin1_General_CP1_CI_AS.

Is SQL_Latin1_General_CP1_CI_AS deprecated?

These are definitely obsolete, even if not officially deprecated, and are mainly for pre-SQL Server 2000 compatibility. Although, quite unfortunately SQL_Latin1_General_CP1_CI_AS is very common due to it being the default when installing on an OS using US English as its language.

What is the difference between SQL_Latin1_General_CP1_CI_AS and Latin1_General_CI_AS?

The SQL_Latin1_General_CP1_CI_AS collation is a SQL collation and the rules around sorting data for unicode and non-unicode data are different. The Latin1_General_CI_AS collation is a Windows collation and the rules around sorting unicode and non-unicode data are the same.


1 Answers

Go to Tools -> Options.

Expand "Sql Server Object Explorer" -> Scripting and there is an option "Include collation" you can enable there in the "Table and view options" category (the default value is false).

screenshot

like image 177
Bridge Avatar answered Sep 19 '22 15:09

Bridge