Thread: Surely not!
View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 08:06 PM
Dan Guzman
 
Posts: n/a
Default Re: Surely not!

Erland, thanks for adding this. I should have included the alternative
DATALENGTH function in my response.

--
Dan Guzman
SQL Server MVP

"Erland Sommarskog" <sommar@algonet.se> wrote in message
news:Xns9449ED1F41AA5Yazorman@127.0.0.1...
> 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