In simple word we can
say sql server string comparison is case sensitive
If we will compare the
strings in sql sever in where clause either using equal to (=)
operator or like operator case sensitiveness will depend upon default collation
of your database. That is if your collation is case sensitive then comparison
will case sensitive and if collation is case insensitive then comparator will
not case sensitive.
In sql sever
default case default collation is SQL_Latin1_General_CP1_CI_AS. It
case insensitive (CI) and ascent sensitive (AS)
DECLARE @Str AS VARCHAR(20) = 'ExactHelp'
IF @Str = 'exacthelp'
SELECT 'Case insensative'
ELSE
SELECT 'Case sensative'
Output: Case insensitive
Sql query to
know default collation name of your database name:
SELECT DATABASEPROPERTYEX('Database_Name', 'Collation')
Example of case sensitive comparison in sql sever:
DECLARE @Str AS VARCHAR(20) = 'ExactHelp'
IF @Str = 'exacthelp' COLLATE SQL_Latin1_General_CP1_CS_AS
SELECT 'Case insensitive'
ELSE
SELECT 'Case sensitive'
Output: Case sensitive
Note: SQL_Latin1_General_CP1_CS_AS
is case sensitive (CS) as well as ascent sensitive (AS)
collation.
What is sql server Send an email when data of any columns of table changes in sql server
Use of stored procedure SP_EXECUTE with examples in sql server
Sql server restrict the stored procedure naming convention
Default sort order of a SELECT statement in Sql server
What is sql server Send an email when data of any columns of table changes in sql server
Use of stored procedure SP_EXECUTE with examples in sql server
Sql server restrict the stored procedure naming convention
Default sort order of a SELECT statement in Sql server
No comments:
Post a Comment