SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Collation issue between tempdb and the database xxx - Better Solution?


Collation issue between tempdb and the database xxx - Better Solution?

Author
Message
Aparna-1
Aparna-1
Old Hand
Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)

Group: General Forum Members
Points: 325 Visits: 601
Hi ,

I have run into collation issues between tempdb and the database.

tempdb - collation is SQL_Latin1_General_CP1_CI_AS
Database(xxx) is Latin1_General_CI_AS

My Sp errors out reporting the collation conflict when a join is based on string fields.

I have temperorily fixed this issue by forcing my temp table to use the database xxx collation.

EX:
CREATE TABLE #BusinessDate
(
RequestID VARCHAR(10) COLLATE Latin1_General_CI_AS,
FileName VARCHAR(100) COLLATE Latin1_General_CI_AS,
FileTypeID INT,
BusinessDate VARCHAR(8) COLLATE Latin1_General_CI_AS
)

And Now my Sp works correctly.

Is there a better solution where i can define in my sp to force the collation to the database default once rather than defining for every column of the temp table?

Thanks in advance
Aparna
gandhi.mk
gandhi.mk
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 10
Hi,

Try with collate statement in the TSQL Query.

Example after where class " Collate DATABASE_default "

Gandhi M.K.
Agaram Instrument, skalar.
gandhi.mk@agaramindia.com
Aparna-1
Aparna-1
Old Hand
Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)

Group: General Forum Members
Points: 325 Visits: 601
Hi,

I could not find a solution to define at the sp level but I have found a way to make it more generic
using database_default

So if there are collation issues because of differences in the tempdb and the database in which you are running the query use database_default for more generic solution

CREATE TABLE #BusinessDate
(
RequestID VARCHAR(10) COLLATE database_default,
FileName VARCHAR(100) COLLATE database_default,
FileTypeID INT,
BusinessDate VARCHAR(8) COLLATE database_default
)

Aparna
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search