Cannot resolve collation conflict for column 1 in SELECT statement

SELECT TABLE_SCHEMA+'.'+name FROM Cognos_Security.dbo.sysobjects,INFORMATION_SCHEMA.COLUMNS WHERE name  =TABLE_NAME and type = 'U'
--Gives "Cannot resolve the collation conflict in the equal to operation." error

I changed it to
SELECT TABLE_SCHEMA+'.'+name FROM Cognos_Security.dbo.sysobjects,INFORMATION_SCHEMA.COLUMNS WHERE name COLLATE DATABASE_DEFAULT =TABLE_NAME COLLATE DATABASE_DEFAULT and type = 'U'

Now it gives the "Cannot resolve collation conflict for column 1 in SELECT statement." error.

what is the cause for this?
LVL 6
anushahannaAsked:
Who is Participating?
 
halfbloodprinceCommented:
0
 
Om PrakashCommented:
Please check the following KB:
Schema: How do I show the columns for a table?
http://databases.aspfaq.com/schema-tutorials/schema-how-do-i-show-the-columns-for-a-table.html

0
 
halfbloodprinceCommented:
See if this helps:

Cannot resolve collation conflict for equal to operation.

In MS SQL SERVER, the collation can be set in column level. When compared 2 different collation column in the query, this error comes up.

SELECT ID
FROM ItemsTable
INNER JOIN AccountsTable
WHERE ItemsTable.Collation1Col = AccountsTable.Collation2Col

If columns ItemsTable.Collation1Col and AccountsTable.Collation2Col have different collation, it will generate the error “Cannot resolve collation conflict for equal to operation“.

To resolve the collation conflict add following keywords around “=” operator.

SELECT ID
FROM ItemsTable
INNER JOIN AccountsTable
WHERE ItemsTable.Collation1Col COLLATE DATABASE_DEFAULT
= AccountsTable.Collation2Col COLLATE DATABASE_DEFAULT

0
 
anushahannaAuthor Commented:
Thanks. Right on.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.