Click or drag to resize

SA0059B : Check for usage of collation different than the database default or the specified collation

The topic describes the SA0059B analysis rule.

Message

Check for usage of collation different than the database default or the specified collation

Description

The rule checks T-SQL script for different than the database default or the specified collation.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters
NameDescriptionDefault Value
Collation

Specific collation to check for.

Database Collation

Remarks

The rule requires Analysis Context. If context is missing, the rule will be skipped during analysis.

Categories

Design Rules

Additional Information

There is no additional info for this rule.

Example Test Script
 1/* Enter T-SQL script to test your analysis rule. */
 2CREATE TABLE TestTab
 3   (PrimaryKey int PRIMARY KEY,
 4    CharCol char(10) COLLATE French_CI_AS
 5   )
 6
 7/* Enter T-SQL script to test your analysis rule. */
 8CREATE TABLE TestTab
 9   (PrimaryKey int PRIMARY KEY,
10    CharCol char(10) COLLATE database_default
11   )
12SELECT *
13FROM TestTab
14WHERE CharCol LIKE N'abc'
15
16CREATE TABLE TestTab (
17   id int, 
18   GreekCol nvarchar(10) collate greek_ci_as, 
19   LatinCol nvarchar(10) collate latin1_general_cs_as
20   )
21INSERT TestTab VALUES (1, N'A', N'a');
22
23SELECT * 
24FROM TestTab 
25WHERE GreekCol = LatinCol COLLATE greek_ci_as;
26
27SELECT (CASE WHEN id > 10 THEN GreekCol ELSE LatinCol END) COLLATE Latin1_General_CI_AS 
28FROM TestTab
29
30SELECT LatinCol COLLATE Latin1_General_CS_AS 
31FROM TestTab

Analysis Results

 MessageLineColumn
1SA0059B : The used collation is different than the expected collation Cyrillic_General_CI_AS.429
2SA0059B : The used collation is different than the expected collation Cyrillic_General_CI_AS.1833
3SA0059B : The used collation is different than the expected collation Cyrillic_General_CI_AS.1933
4SA0059B : The used collation is different than the expected collation Cyrillic_General_CI_AS.2534
5SA0059B : The used collation is different than the expected collation Cyrillic_General_CI_AS.2767
6SA0059B : The used collation is different than the expected collation Cyrillic_General_CI_AS.3024
See Also

Other Resources