T-sql Like statement and trailing zeros
Using SQL Server, imagine you have decimal stored as a nvarchar and you
want to compare it to another nvarchar using 'like'. Assuming you provide
the significant digits, this should be fine (albeit not ideal):
declare @test1 nvarchar(18);
declare @test2 nvarchar(18);
set @test1 = '1.15%';
set @test2 = '1.1500000000000000';
select
case when @test1 like @test2 then 'Yes'
else 'No'
end as result;
This returns the result of 'No', why is that the case?
No comments:
Post a Comment