Bob
2012-06-07 20:07:31 UTC
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
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