I was wondering if anyone could explain this behavior?
DECLARE @RandomParam1 NVARCHAR
DECLARE @RandomParam2 NVARCHAR
DECLARE @RandomParam3 NVARCHAR
SET @RandomParam1 = '0HelloWorld'
SET @RandomParam2 = '9HelloWorld'
SET @RandomParam3 = '15HelloWorld'
select 1 where '0' = @RandomParam1
select 1 where '0' = '0HelloWorld'
select 1 where '9' = @RandomParam2
select 1 where '15' = @RandomParam3
Why does comparing strings with parameters give a different result than without parameters? And why does he claim that '0' = '0whatever'?
I get that it may be that the parameter is trying to compare it as numbers, but then the last example should also be true.
Any ideas?
source
share