Data Warehousing and Business Intelligence

2 April 2011

Collation Conflict When Querying a Linked Server

Filed under: SQL Server — Vincent Rainardi @ 7:45 am
Tags:

Sometimes we want to query a table on a linked server, to compare with data from the local SQL Server like this:

select * from LinkServer1.Database1.dbo.Table1
where Column1 in (select Column2 from Schema1.Table2)

When we do that we may get this error:

Msg 468, Level 16, State 9, Line 1
Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_CI_AS” in the equal to operation.

This is because the collation is different between the two SQL Servers. To solve this convert the collation using “collate database default” like this:

select * from LinkServer1.Database1.dbo.Table1
where Column1 collate database_default in
(select Column2 from Schema1.Table2)

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: