• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

How to specify Collate when creating temp tables

Hi,

I create following temp table:
         
CREATE TABLE #MyTemp(        
 [Desc] [nvarchar] (50),        
 [Code] [smallint],        
 [Ikey] [smallint]  
)        

Now how do I specify COLLATE SQL_Latin1_General_CP1_CI_AS collation for this table? Note that it should run on both SQL 2000 and SQL 2005

Regards,
MI

       
0
vj_mi
Asked:
vj_mi
  • 2
1 Solution
 
adatheladCommented:
Hi,

Set it for the appropriate columns, like this:

CREATE TABLE #MyTemp(        
 [Desc] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS,        
 [Code] [smallint],        
 [Ikey] [smallint]  
)        
0
 
vj_miAuthor Commented:
So do I need to set for all columns or only columns where this table is joined with other tables?

Regards,
MI
0
 
adatheladCommented:
It doesn't matter for the numerical columns.

I presume you were having collation errors, hence why you want to explicitly set the collation? If not, then no need to specify it.

Otherwise, yes I *think* you only need it on the columns used to join on other tables that have a different collation.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now