-- Example of case-sencivity.
Declare @v1 varchar(20), @v2 varchar(20)
SET @v1='nitisH' ; SET @v2='niTisH'
IF(@v1=@v2 COLLATE Latin1_General_CS_AS )
PRINT 'Matched'
Else
PRINT 'Unmatched'
Select Name from MemberMaster where Name = 'niTisH' COLLATE Latin1_General_CS_AS
Keyword ->
COLLATE: Is a clause that can be applied to a database definition or a column definition to define the collation, or to a character string expression
to apply a collation cast.
The COLLATE clause can be applied only for the char, varchar, text, nchar, nvarchar, and ntext data types.
You can use the COLLATE clause of the CREATE DATABASE or ALTER DATABASE statement to specify the default collation of the database. You can also
specify a collation when you create a database using SQL Server Management Studio. If you do not specify a collation, the database is assigned the
default collation of the instance of SQL Server.
You can specify collations for each character string column using the COLLATE clause of the CREATE TABLE or ALTER TABLE statement. You can also specify
a collation when you create a table using SQL Server Management Studio. If you do not specify a collation, the column is assigned the default collation
of the database. You can also use the database_default option in the COLLATE clause to specify that a column in a temporary table use the collation
default of the current user database for the connection instead of tempdb.
You can use the COLLATE clause to apply a character expression to a certain collation. Character literals and variables are assigned the default collation
of the current database. Column references are assigned the definition collation of the column.
database_default: Causes the COLLATE clause to inherit the collation of the current database.
collation_name: Is the name of the collation to be applied to the expression, column definition, or database definition. collation_name can be only a specified
Windows_collation_name or a SQL_collation_name. collation_name must be a literal value. collation_name cannot be represented by a variable or expression.
CaseSensitivity: CI specifies case-insensitive, CS specifies case-sensitive.
AccentSensitivity: AI specifies accent-insensitive, AS specifies accent-sensitive.
/* Find Collation of SQL Server Database */
SELECT DATABASEPROPERTYEX('test_base', 'Collation')
/* Find Collation of SQL Server Database Table Column */
USE test_base
SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN (SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'EmployeeDetails')
--AND name = 'City' -- > can apply over particular column too.
Cheers!!!
Ref:
http://msdn.microsoft.com/en-us/library/ms184391.aspx
http://sqlservernet.blogspot.in/2012/02/case-sensitive-sql-query-search-and.html
http://msdn.microsoft.com/en-us/library/ms180175(v=sql.105).aspx
SELECT * FROM sys.fn_helpcollations() WHERE name LIKE 'SQL%';
Declare @v1 varchar(20), @v2 varchar(20)
SET @v1='nitisH' ; SET @v2='niTisH'
IF(@v1=@v2 COLLATE Latin1_General_CS_AS )
PRINT 'Matched'
Else
PRINT 'Unmatched'
Select Name from MemberMaster where Name = 'niTisH' COLLATE Latin1_General_CS_AS
Keyword ->
COLLATE: Is a clause that can be applied to a database definition or a column definition to define the collation, or to a character string expression
to apply a collation cast.
The COLLATE clause can be applied only for the char, varchar, text, nchar, nvarchar, and ntext data types.
You can use the COLLATE clause of the CREATE DATABASE or ALTER DATABASE statement to specify the default collation of the database. You can also
specify a collation when you create a database using SQL Server Management Studio. If you do not specify a collation, the database is assigned the
default collation of the instance of SQL Server.
You can specify collations for each character string column using the COLLATE clause of the CREATE TABLE or ALTER TABLE statement. You can also specify
a collation when you create a table using SQL Server Management Studio. If you do not specify a collation, the column is assigned the default collation
of the database. You can also use the database_default option in the COLLATE clause to specify that a column in a temporary table use the collation
default of the current user database for the connection instead of tempdb.
You can use the COLLATE clause to apply a character expression to a certain collation. Character literals and variables are assigned the default collation
of the current database. Column references are assigned the definition collation of the column.
database_default: Causes the COLLATE clause to inherit the collation of the current database.
collation_name: Is the name of the collation to be applied to the expression, column definition, or database definition. collation_name can be only a specified
Windows_collation_name or a SQL_collation_name. collation_name must be a literal value. collation_name cannot be represented by a variable or expression.
CaseSensitivity: CI specifies case-insensitive, CS specifies case-sensitive.
AccentSensitivity: AI specifies accent-insensitive, AS specifies accent-sensitive.
/* Find Collation of SQL Server Database */
SELECT DATABASEPROPERTYEX('test_base', 'Collation')
/* Find Collation of SQL Server Database Table Column */
USE test_base
SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN (SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'EmployeeDetails')
--AND name = 'City' -- > can apply over particular column too.
Cheers!!!
Ref:
http://msdn.microsoft.com/en-us/library/ms184391.aspx
http://sqlservernet.blogspot.in/2012/02/case-sensitive-sql-query-search-and.html
http://msdn.microsoft.com/en-us/library/ms180175(v=sql.105).aspx
SELECT * FROM sys.fn_helpcollations() WHERE name LIKE 'SQL%';