SQL Server collation and temp tables · Fri Aug 26, 05:01 PM
If you receive an error along the lines of “Cannot resolve collation conflict for equal to operation,” and you’re using a temp table, a table variable in a stored proc, or a table-valued UDF, the probable cause is a mismatch between the collation settings for your current database and your tempdb. There are a few different ways to fix this, but the easiest is probably to append “COLLATE database_default” to the table declarations in the UDF or proc.
Example:
Before being fixed:
CREATE FUNCTION dbo.ReturnMyTable (
@ParamVal nvarchar (2000)
)
RETURNS
@RtnTable table
(
EachItem nvarchar (450)
)
AS
BEGIN
-- Fill in functionality here
END
After fix:
CREATE FUNCTION dbo.ReturnMyTable (
@ParamVal nvarchar (2000)
)
RETURNS
@RtnTable table
(
EachItem nvarchar (450) COLLATE database_default
)
AS
BEGIN
-- Fill in functionality here
END
-- David --
...
Archive by Date
- Administrative (51)
- Art (3)
- Books (14)
- Business (1)
- Clocks (8)
- Dating (1)
- Events (7)
- Flickr (1)
- Fonts (8)
- Human-Nature (1)
- Humor (5)
- Military (4)
- Misc (121)
- Movies (5)
- Music (68)
- OLE-DB (1)
- Poetry (4)
- Quotes (5)
- Relationships (1)
- Security (1)
- Shoes (2)
- Software (115)
- Spirits (11)
- Surveys (1)
- Tequila (6)
- Virtualization (9)
- Web (9)
- Website (20)
- Wood-Related (2)
- Writing (7)

