Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Data Length

Author  Topic 

atmonline
Starting Member

14 Posts

Posted - 2008-07-10 : 12:54:11
I need to store a user comment in comment field of my table.
The length of Comments field in table is varchar(7000).
But one user comment is 7250 characters long.I was asked to truncate the data . how do i do that.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-10 : 13:05:46
You can Len function.
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-07-10 : 13:46:38
select left(commentfield, 7000) assuming you want the 1st 7000 positions,
select right(commentfield, 7000) assuming you want the right most 7000,
you can even use: select substring(commentfield, 1, 7000) to get the 1st 7000 (this accomplishes the same thing as the left). All this is in BOL.

Terry
Go to Top of Page

atmonline
Starting Member

14 Posts

Posted - 2008-07-10 : 15:19:33
Thanks
Go to Top of Page
   

- Advertisement -