Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collation conflict ERROR ,Set collation for stored procedure as database default

How can I set for COLLATION for stored procedure as Database default rather than individual column of tables in that procedure .

Cannot resolve the collation conflict between “SQL_Latin1_General_Pref_CP1_CI_AS” and “Latin1_General_CI_AS” in the equal to operation

I am getting collation conflict error as database server collation is different from database collation. The procedure is huge and I don't know on which table column conflict is occuring.

Is it even possible to assign collation for stored procedure such that all columns in that procedure have same collation?

like image 469
Mudassir Hasan Avatar asked Dec 03 '12 04:12

Mudassir Hasan


People also ask

How do you solve Cannot resolve the collation conflict between SQL_Latin1_General_CP1_CI_AS and Latin1_General_CI_AS in the equal to operation?

Issue: Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_CI_AS” Simply apply the default collation to the fields you are comparing.

How do I change the default database collation?

You can change the collation of any new objects that are created in a user database by using the COLLATE clause of the ALTER DATABASE statement. This statement does not change the collation of the columns in any existing user-defined tables. These can be changed by using the COLLATE clause of ALTER TABLE.

How do I find my default database collation?

To see the default collation for each character set, use the SHOW CHARACTER SET statement or query the INFORMATION_SCHEMA CHARACTER_SETS table. If COLLATE collation_name is specified without CHARACTER SET , the character set associated with collation_name and collation collation_name are used.

What is default database collation?

Default server-level collation is SQL_Latin1_General_CP1_CI_AS.


1 Answers

Firstly, collation is about how the textual data is stored within a table and is not at a stored procedure level.

Collation issues occur when textual data is compared from sources where the text collatation is not stored the same. (I am not talking about the data type of text, just string data)

Check the TSQL where clauses or table joins, this is the most common places where text compares occur. You can collate to the database default by using the collate function next to the compare area. For example

SELECT
c.CustomerID
FROM
dbo.Customer c
INNER JOIN dbo.CustomerLog cl on c.CustomerName = cl.LogEntry collate     
database_default

Depending on your circumstance this might not be possible but I always follows these rules.
- Choose the correct server default collation at install so the tempdb is created under the collation, when you create temp tables, these are created in the tempdb
- when creating tables do not specifiy the collation unless you have specific cause to

like image 154
user1846472 Avatar answered Sep 20 '22 11:09

user1846472