Is there any way to compare two strings in SQL Server 2008 stored procedure like below?
int returnval = STRCMP(str1, str2)
- returns 0 if the strings are the same
- returns -1 if the first argument is smaller than the second according to the current sort order.
- returns 1 otherwise.
Above method I find in the MySQL but not in SQL Server.
There is no built-in string compare function in SQL Server, you have to do it manually:
Notes:
CREATE FUNCTIONetc.str1andstr2will be column names or @variables