Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot resolve the collation - tempdb..#Carriers

Posted on 2016-08-12
3
Medium Priority
?
97 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 1000 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 52

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 1000 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 52

Accepted Solution

by:
Vitor Montalvão earned 1000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

722 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