Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

T-SQL Table variable with case sensitive columns - collate SQL_Latin1_General_CP1_CS_AS

Is it possible to have collate SQL_Latin1_General_CP1_CS_AS in table variable columns' definitions?

The reason I want to do this is because I have case sensitive information in my source table but when I insert it in the table variable there is a problem with the primary key (it is clustered) - duplicated values are detected - like 'All' and 'ALL'.

That's why I am trying to find a way to make the table variable columns case sensitive too as the following statement:

SELECT SERVERPROPERTY ('Collation')

gives me: "SQL_Latin1_General_CP1_CI_AS"

like image 465
gotqn Avatar asked Aug 13 '12 08:08

gotqn


1 Answers

Yes it is possible. You can specify the collation for each column when you declare your table variable.

declare @T table
(
  Col varchar(20) collate SQL_Latin1_General_CP1_CS_AS
)
like image 68
Mikael Eriksson Avatar answered Oct 02 '22 07:10

Mikael Eriksson