I’m using SQL Server 2008.
I have found the LEN function does not return a zero when it evaluates an integer when the integer has no value – it returns a 1.
For example:
declare @int1 int
set @int1 = ''
select LEN(@int1)
A 1 is returned instead of a zero! But the integer is zero-length!
Why is this? Is it a bug?
An INT doesn’t have a length. This is what you are actually doing…
''0'0'The result of which is that your LEN function is not being called on ”, but is infact being called on ‘0’, which has a length of 1.