Alex A
asked on
T-SQL: max lenth of text in nvarchar(4000)
Hi, how to determine maximum lenth of existing text in SQL Server table nvarchar(4000) column?
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can use ltrim, rtrim of you dont wont to count spaces
SELECT MAX( LEN(ltrim(rtrim(ColumnName ))) ) from yourTable
SELECT MAX( LEN(ltrim(rtrim(ColumnName
luani wrote:
That would only strip out leading and/or trailing spaces, and will leave intact any internal spaces.
That said, if the concern is for trailing spaces, then as PortletPaul already indicates, LEN() already leaves those out...
you can use ltrim, rtrim of you dont wont to count spaces
That would only strip out leading and/or trailing spaces, and will leave intact any internal spaces.
That said, if the concern is for trailing spaces, then as PortletPaul already indicates, LEN() already leaves those out...
Whereas len() is the number of characters (but one character can be multi-byte) and it excludes trailing blanks.