Wednesday, March 7, 2012

returning string length

I need to write a query that tells me which string values are empty or
blank in a table.

Is it possible to return the length of the string contained in character
field?Look at the LEN function.
If you need to determine if it is null, use IS NULL to evaluate it.

Regards
--
----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"William Kossack" <kossackw@.njc.org> wrote in message
news:10rh4pnoqegec3d@.corp.supernews.com...
> I need to write a query that tells me which string values are empty or
> blank in a table.
> Is it possible to return the length of the string contained in character
> field?|||Or DataLength|||Ryan (ryanofford@.hotmail.com) writes:
> Or DataLength

There are a couple of differences between len() and datalength()

o len() gives the length in charcters, datalength() in bytes (which
matters for nchar/nvarchar).
o len() excludes trailing blanks, datalength does not.
o datalength() is the only one to work on text/ntext/image.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

No comments:

Post a Comment