Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2004-12-14 : 13:04:13
|
| can I do something like this? I keep getting an error...Update mSet m.SubFirstname = case( when m.Relationship IN ('Child', 'Spouse') And a.p_asi_cd IN ('XX','XA') then m.SubFirstname = n.p_name_firstELSE m.SubFirstname = x.p_name_firstEND )From #final m Left Join ac_p_asi a on m.p_id = a.p_assoc_idLeft Join ac_p_name n on a.p_id = n.p_idjoin #final X on m.p_id = x.p_id |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-12-14 : 13:07:08
|
| Posting the error would be helpful.Tara |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-12-14 : 14:24:17
|
removing the ( after the case and after the end maay help...Set m.SubFirstname = case( when m.Relationship IN ('Child', 'Spouse') And a.p_asi_cd IN ('XX','XA') then m.SubFirstname = n.p_name_firstELSE m.SubFirstname = x.p_name_firstEND )Go with the flow & have fun! Else fight the flow |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-14 : 14:44:17
|
remember -- CASE returns a value; nothing else, it cannot control flow of execution or anything. consider it a function.you are trying to do your assignment in the CASE statement, which is not allowed. and also, it is redundant -- you've already indicated you are going to be assigning to the subFirstName column in the very beginning of the UPDATE statement.update SomeTableSet m.SubFirstname = case when m.Relationship IN ('Child', 'Spouse') And a.p_asi_cd IN ('XX','XA') then n.p_name_first ELSE x.p_name_first END- Jeff |
 |
|
|
C0dewarr10r
Starting Member
3 Posts |
Posted - 2004-12-14 : 16:44:35
|
| Is it possible to dynamically change the qualifier "=" to one of the following based on an input parameter - "<", ">", "<=", ...-> dynamically modifying the where clause: date = @input param date < @input param date > @input paramupdate tableset name = 'Johnny'where date case when @datequailifer = 'eq' then '= @input param when @datequailifer = 'lt' then '< @input param when @datequailifer = 'gt' then '> @input param EndThanks |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
|
|
|
|
|
|
|