Thread: Surely not!
View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 08:06 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Surely not!

DMAC (drmcl@drmcl.free-online.co.uk) writes:
> I know I must be missing something pretty obvious, but what setting
> should I change to get the correct length of my string ie why does the
> select statement below return 1 when it looks fairly obvious that the
> second string is a tad longer than 1
>
> select len('a ')
> select len('a ')


In addition to Dan's response, if you need to know the length including
the trailing blanks, use the datalength() function. Beware that this
function returns the length in bytes, so if you use datalength on
Unicode data, you need to divide the result by two to get the length
in characters.

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Reply With Quote