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)
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)
Labels:
SQL Server 2000,
SQL Server 2005,
SQL Server 2008,
Teaser
Subscribe to:
Post Comments (Atom)
1 comment:
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 :)
Post a Comment