Reputation: 3437
I have a field with datatype VARCHAR and MAX length. However, I just want to print only the first 2000 characters from that field. I cannot use VARCHAR(2000) as the datatype for the field upon table creation since there are a records exceeding this length and as you might all know, this results in a 'String or binary data would be truncated' error.
What I'm doing is sending an email report which may get too lengthy because of that field so I just want to output the first 2000 characters.
Any help would be greatly appreciated! Thanks in advance!
Upvotes: 4
Views: 16458
Reputation: 220
you can use substring.
select SUBSTRING(yourcolumnname,0,2000) from yourtablename
Upvotes: 9