December 23, 2009 at 12:36 pm
Can anyone tell me why the following returns true? I can't help but wonder if it's a server-specific COLLATION setting or something like that, but I'm not sure:
DECLARE @C VARCHAR(10)
,@i VARCHAR(10)
SET @i=192
SET @C=CHAR(@i)
SELECT
,CASE WHEN @C LIKE '[A-Fa-f]' THEN 'true' ELSE 'false' END AS TestResult
December 23, 2009 at 12:39 pm
yes.
The probability of survival is inversely proportional to the angle of arrival.
December 23, 2009 at 3:22 pm
sturner - Uh....yes you can explain it (but chose not to) or yes it is a collation setting (but you don't want to ellaborate).
December 23, 2009 at 4:50 pm
Never mind, found the info I needed here:
http://www.databasejournal.com/features/mssql/article.php/3302341/SQL-Server-and-Collation.htm
So changing the code above to this, fixed it:
DECLARE @C VARCHAR(10)
,@i VARCHAR(10)
SET @i=192
SET @C=CHAR(@i)
SELECT
,CASE WHEN @C COLLATE Latin1_General_BIN LIKE '[A-Fa-f]' THEN 'true' ELSE 'false' END AS TestResult
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply