Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql server update statement with string concatination?

Status
Not open for further replies.

vituja

Programmer
Oct 1, 2003
30
US
Hi All,

I'm trying to do something like this:

Update ID_TBL set rights=rights + 'TMEPJMAINT1'
where TMEPJMAINT where netid in ('vituja','leelil','howlro','schwsu','kerkel')

But the rights=rights + is not working. I know this is easy but I've haven't done this type of coding in a while.

Any help would be appreciated. Thanks.
 
WHat error are you getting or is it just not putting the nformation in correctly? If the latter, what is it doing to the information?

Questions about posting. See faq183-874
 
The sql statement,

Update ID_TBL set rights=rights + 'TMEPJMAINT1'
where netid in ('vituja','leelil','howlro','schwsu','kerkel')

returned an error:
Server: Msg 8152, Level 16, State 9, Line 1
String or binary data would be truncated.
The statement has been terminated.

 
I believe this means that the rights field in your ID_TBL is too short to hold the new value that you want to update it to. For example, if rights is a varchar field with length of 10, and you are trying to update it with a value that has a length greater than 10, then you would end up truncating the new value. You could probably just set the length to permit a larger value.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Insteresting. That could be the case. So the syntax is fine then?
 
It looks ok to me, for what little bit that may be worth.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
That was it. Thanks Chopstik. The size of the field was too small.

Thanks also to SQLSister!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top