Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Changing the collation of data during insert

Author  Topic 

seethem
Starting Member

46 Posts

Posted - 2011-12-05 : 09:23:26
Folks,

I have two databases - A_SOURCE and B_DESTINATION - in the same instance.

The source table resides in A_SOURCE with the collation Latin1_General_CI_AS.

The destination table resides in B_DESTINATION with the collation SQL_Latin1_General_CP1_CI_AS.

I have a view in B_DESTINATION that looks like:
CREATE VIEW get_data_from_A
AS
select [NAME] collate SQL_Latin1_General_CP1_CI_AS AS [NAME]
from A_SOURCE..source_tbl


In B_DESTINATION I try to populate the destination table as follows:
INSERT INTO dest_tbl (Name)
select Name from get_data_from_A;

------------
Why is the collation still Latin1_General_CI_AS? I want it to change to the collation of the destination. What do I need to do?


Warm regards,

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-12-05 : 09:57:08
Have a look at the collation of the column in the destination table - that will define what it gets converted to. It may be different from the database collation.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

seethem
Starting Member

46 Posts

Posted - 2011-12-05 : 10:36:07
I got an answer...

1) I checked the collation values of the column:
SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLLATION_NAME
FROM B_DESTINATION.INFORMATION_SCHEMA.COLUMNS
WHERE COLLATION_NAME is not null AND TABLE_NAME='dest_tbl'

2) Ran the alter database command from the following site:
http://www.sqlusa.com/bestpractices/changecollation/

Thanks for the help...
Go to Top of Page
   

- Advertisement -