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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this possible? 1

Status
Not open for further replies.

nzgirl

Programmer
Feb 26, 2003
72
NZ
I want to run 3 update queries in a row over the same table on the same field.
ie
update Trial set Prob = 'D' where Condition1 = true
update Trial set Prob = 'E' where Condition2 = true
update Trial set Prob = 'F' where Condition3 = true

If a record has both Condition1 and Condition2 true I want Prob to end up as 'DE'
I've got it set as a 4 Char.
and I tried
update Trial set Prob = Prob + 'E' where Condition2 = true
update Trial set Prob = Prob + 'F' where Condition3 = true
but it spat a fit bout truncation...

can you append a char string in SQL?
If so... how?

Thanks
:)
 
that is because CHAR(4) pads spaces
So what you get is the first statement making the column
"D "
then when you try to + 'E' it would be
"D E" which is more than CHAR(4)
change the definition to varchar(4) or
I want to run 3 update queries in a row over the same table on the same field.
ie
update Trial set Prob = LTRIM(RTRIM(Prob)) + 'D' where Condition1 = true
update Trial set Prob = LTRIM(RTRIM(Prob)) + 'E' where Condition2 = true
update Trial set Prob = LTRIM(RTRIM(Prob)) + 'F' where Condition3 = true
 
Perfect! I knew I was missing just a little something!
Thanks :)
 
Glad to help!

Psst! tell you a secret. Something I learnt when I started teaching. I've learnt A LOT from having people ask me questions. It makes me think more then just dabbling myself. Students come up with questions about so many things that you just don't think of or take for granted and they want to know why! Love these boards 8)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top