Solved

Cannot resolve the collation - tempdb..#Carriers

Posted on 2016-08-12
3
73 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 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 50

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 50

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

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

Suggested Solutions

Title # Comments Views Activity
Adding columns to a table which has non null columns 3 41
SQL Procedure 7 48
Create a Calendar table 29 43
invoke-sqlcmd help 5 30
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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
Viewers will learn how the fundamental information of how to create a table.

739 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