Wednesday, December 12, 2007

SQL Teaser: LEN vs DATALENGTH

This should trip up some people.....

Without running this code what do you think will LEN and DATALENGTH return?

DECLARE @i int
SELECT @i =' 123456789 '

SELECT @i,LEN(@i),DATALENGTH(@i)

1 comment:

Scott Whigham said...

Hmmmm - I would expect DATALENGTH to return 4 and LEN to return 0 since, in my mind, I expect LEN to only be useful for strings...

.... testing... 1, 2, 3

Interesting...

Thanks :)