Monday, October 1, 2007

[mssql] Getting Length of A Text Field

Answer:
Just use the datalength function instead of the len function.
Example:

SELECT datalength(notes) FROM MyTable (NOLOCK)

Background:
select len(notes) from Mytable
Gives me this error:
Server: Msg 8116, Level 16, State 2, Line 1
Argument data type text is invalid for argument 1 of len function.

http://www.answermysearches.com/ms-sql-server-getting-length-of-a-text-field/138/

No comments:

Post a Comment