Solved

Cannot resolve the collation - tempdb..#Carriers

Posted on 2016-08-12
3
42 Views
Last Modified: 2016-08-15
i have this code

insert into #Carriers (CarrierTrackingNumber)
select distinct top 1000 CarrierTrackingNumber
from Sales.SalesOrderDetail d
      join #Carriers c on d.CarrierTrackingNumber = c.CarrierTrackingNumber
where d.ProductID = 776

this is error:
Msg 468, Level 16, State 9, Line 524
Cannot resolve the collation conflict between "Modern_Spanish_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
Msg 209, Level 16, State 1, Line 524
Ambiguous column name 'CarrierTrackingNumber'.

SELECT CONVERT (varchar, DATABASEPROPERTYEX('AdventureWorks','collation'));  
SQL_Latin1_General_CP1_CI_AS

SELECT CONVERT (varchar, DATABASEPROPERTYEX('tempdb,'collation'));  
Modern_Spanish_CI_AS
0
Comment
Question by:enrique_aeo
  • 2
3 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 250 total points
ID: 41753942
for ambigous error
 

 change "select distinct top 1000 CarrierTrackingNumber " to

select distinct top 1000 d.CarrierTrackingNumber


for the collation error, you can redefine the temp table with proper collation , in this case SQL_Latin1_General_CP1_CI_AS
0
 
LVL 45

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 250 total points
ID: 41753943
Ambiguous column name 'CarrierTrackingNumber'.
You need to add the table alias (c or d) in the SELECT statement. For example:

select distinct top 1000 d.CarrierTrackingNumber
0
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 250 total points
ID: 41753946
The collation error means that you're database, table or column has a different collation from the SQL Server instance collation. This means that you need to explicitly say which collation that you want to use:

join #Carriers c on d.CarrierTrackingNumber = c.CarrierTrackingNumber COLLATE Modern_Spanish_CI_AS
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
The duplicate key value is (<NULL>) 14 46
Numeric sequence in SQL 14 37
SQL Inner Join Vs SubQueries 9 25
SQL Maintenance Plan 3 16
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now