Solved

Collation for Create Table

Posted on 2007-11-30
5
1,152 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the best way to calculate hours worked 5 71
SQL Encryption question 2 57
Truncate vs Delete 63 105
Bubble user-defined Sql RAISERROR(...) to c# exception 14 169
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

823 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