Solved

Cannot resolve the collation - tempdb..#Carriers

Posted on 2016-08-12
3
51 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 46

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 46

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

861 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

24 Experts available now in Live!

Get 1:1 Help Now