Solved

Collation for Create Table

Posted on 2007-11-30
5
1,138 Views
Last Modified: 2010-05-18
When creating tables with CREATE TABLE, how do I make sure, that SQL Server 2005 uses the Database defautl collation and not the Servers collation??
Right now, I do not have any collations integrated in my scripts.

Chris

e.g.
      
      
      CREATE TABLE [dbo].[tkey_wdKennungTyp](
            [idKennungTyp] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF__tkey_wdKennungTyp__idKennungTyp]  DEFAULT (newid()),
            [KennungTyp] [varchar](255) NULL,
            [KennungTypID] [int] NULL,
            [KennungTypJaNein] [int] NULL,
            [New] [datetime] NULL CONSTRAINT [DF__tkey_wdKennungTyp__New]  DEFAULT (getdate()),
       CONSTRAINT [PK_tkey_wdKennungTyp] PRIMARY KEY NONCLUSTERED ([idKennungTyp] ASC)
       ) ON [PRIMARY]
0
Comment
Question by:chriswies
  • 3
  • 2
5 Comments
 

Author Comment

by:chriswies
ID: 20381707
btw: right now, the collation on my development system is
      'SQL_Latin1_General_CP1_CI_AS'
when I just saw the difference in my VM testsytem, it was
      'Latin1_General_CI_AS'

I would have the chance to switch. I would choose  'SQL_Latin1_General_CP1_CI_AS' because the MS Access upsizing wiz choose it a few month ago :-)
Do you have any advise which one is better/more appropiate/higher performance...? --> my users language is german; keep that in mind for your advise.
Chris
0
 

Author Comment

by:chriswies
ID: 20381712
there are two questions, now -> more points
0
 
LVL 6

Expert Comment

by:PaultheBroker
ID: 20381976
from BOL 2000 - CREATE TABLES

"Specifies the collation for the column. Collation name can be either a Windows collation name or a SQL collation name. The collation_name is applicable only for columns of the char, varchar, text, nchar, nvarchar, and ntext data types. If not specified, the column is assigned either the collation of the user-defined data type, if the column is of a user-defined data type, or the default collation of the database."

So my understanding is that when you create the database, the collation defaults to that of the server, but then when you create tables under the database, the database collation is used.  So the answer to your first question is "you don't need to - the server collation won't be considered"

Obviously you can define collation at the column level to override the database default.
0
 

Author Comment

by:chriswies
ID: 20382036
and what is the difference between
SQL_Latin1_General_CP1_CI_AS
and
Latin1_General_CP1_CI_AS

Any Idea?
Chris
0
 
LVL 6

Accepted Solution

by:
PaultheBroker earned 500 total points
ID: 20382066
CPI1 treats unicode data differently from nonunicode:  Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 52 on Code Page 1252 for non-Unicode Data

'Latin1_General_CI_AS':  Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive

more info here:
http://msdn2.microsoft.com/en-us/library/aa176551(SQL.80).aspx

Also, if you run

SELECT *
FROM ::fn_helpcollations()

you will see some other options, including a whole set of German_phonebook collations.

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now