variable FIELD query
- From: Bob <Go1369@xxxxxxxxx>
- Date: Thu, 7 Jun 2012 13:07:31 -0700 (PDT)
Hi folks. I previously posted this question but I made an error in my
example.
I need to update a column of a table based on the pri. key.
I tried using Case like this
Case @MIY
When 0 Then Update dbo.EMI Set fieldA=@insertString Where CID=@CID
When 1 Then Update dbo.EMI Set fieldB=@insertString Where CID=@CID
When 2 Then Update dbo.EMI Set fieldC=@insertString Where CID=@CID
When 3 Then Update dbo.EMI Set fieldD=@insertString Where CID=@CID
End
That didn't work so I tried
If @MIY=0
Begin
Update dbo.EMI Set fieldA=@insertString Where CID=@CID
End
If @MIY=1
Begin
Update dbo.EMI Set fieldB=@insertString Where CID=@CID
End
ect ect ect (I have 11 IF's)
That didn't work either, although I saw other examples that seemed to
work. What am I missing?
Anybody got any ideas?
Thanks, Bob
.
- Follow-Ups:
- Re: variable FIELD query
- From: rpresser
- Re: variable FIELD query
- From: Erland Sommarskog
- Re: variable FIELD query
- Prev by Date: Re: Case question
- Next by Date: Re: variable FIELD query
- Previous by thread: Case question
- Next by thread: Re: variable FIELD query
- Index(es):