DATALENGTH function

If you get the error “Argument data type XXXX is invalid for argument 1 of len function.” then you’ll need to use the DATALENGTH function instead.
I typically get this when I want to know how many bytes (how big) an image or binary field is in SQL Server.
Note: For strings the trailing spaces WILL be counted, which isn’t the case with LEN.

See also DATALENGTH (Transact-SQL)
and LEN (Transact-SQL)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s