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 |
|
agarwasa2008
Posting Yak Master
109 Posts |
Posted - 2009-09-01 : 21:24:31
|
| I would really appreciate some feedback on this!!insert into table1 (col1, col2, col3, col4)select @Variable1, col2, col3, col4from table2 where col2=@Variable2Is the above query correct and how can I assign each of the variables the 2 values. Depending on the situation for ex. if var1=45 then var2=12435 (gets specific value)Thanks!!SA |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-09-02 : 02:44:27
|
| Depending on the situation for ex. if var1=45 then var2=12435 (gets specific value)can u explain more clearly.. is var2,var1 are columns in table2? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-02 : 03:03:28
|
| something likeselect @Variable2=case when @Variable1=45 then 12435 else 100 endinsert into table1 (col1, col2, col3, col4)select @Variable1, col2, col3, col4from table2 where col2=@Variable2MadhivananFailing to plan is Planning to fail |
 |
|
|
agarwasa2008
Posting Yak Master
109 Posts |
Posted - 2009-09-02 : 12:34:15
|
| Thanks. It works like a charm.SA |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-03 : 02:28:15
|
quote: Originally posted by agarwasa2008 Thanks. It works like a charm.SA
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|