August 11, 2011 at 2:22 am
Hi All
I need to query a column in a particular table to find out which entries in that coulmn contain > 4000 characters, including spaces. The column has a 'text, null' datatype.
I've been trying all sorts of LEN and DATALENGTH queries, but I just can't seem to get there. I'm sure it must be easier than I'm thinking! I've even tried converting the column to VARCHAR(MAX) but still no luck.
Any ideas?
Thanks,
P
August 11, 2011 at 2:30 am
What exact syntax have you tried, and what errors, or unexpected results, do you get when you try it?
John
August 11, 2011 at 2:51 am
...in fact, I think I'm there:
SELECT LEN(column)
FROM tablename
WHERE LEN(column) > 0
ORDER BY LEN(column) DESC;
I ended up converting the TEXT datatype on that column to VARCHAR(MAX) first, and then re-trying one of my original attempts, which I think is the reason I was having trouble previously.
I've double-checked by counting the chars in a few of the fields myself and it seems to be correct.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply