Is there any way to compare two strings in SQL Server 2008 stored procedure like below?
int returnval = STRCMP(str1, str2)
Above method I find in the MySQL but not in SQL Server.
This question is related to
sql
sql-server-2008
string-comparison
There is no direct string compare function in SQL Server
CASE
WHEN str1 = str2 THEN 0
WHEN str1 < str2 THEN -1
WHEN str1 > str2 THEN 1
ELSE NULL --one of the strings is NULL so won't compare (added on edit)
END
Notes
Source: Stackoverflow.com