If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Truncating text as per the size of columnin SP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-21-11, 17:22
smartcooldevil smartcooldevil is offline
Registered User
 
Join Date: Jun 2010
Posts: 17
Truncating text as per the size of columnin SP

Hi All,

I have one comment field in my stored procedure which is of the size VARCHAR(200) but the database column I am fetching data from is of 500 VARCHAR.
DB2 does not truncates the text automatically and throws error when I execute my procedure. I dont want to increase the field size in my procedure so how can I restrict to fetch only first 200 characters and ignore other text?

Thanks
Reply With Quote
  #2 (permalink)  
Old 11-21-11, 19:17
TonyF123 TonyF123 is offline
Registered User
 
Join Date: May 2008
Posts: 17
you could use the LEFT() function

select LEFT(<column>,200)

would select the first 200 characters from the column.
Reply With Quote
  #3 (permalink)  
Old 11-22-11, 10:16
smartcooldevil smartcooldevil is offline
Registered User
 
Join Date: Jun 2010
Posts: 17
Thumbs up

Quote:
Originally Posted by TonyF123 View Post
you could use the LEFT() function

select LEFT(<column>,200)

would select the first 200 characters from the column.
Thanks Tony, its working.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On