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 |
linda9898
Starting Member
28 Posts |
Posted - 2007-10-01 : 17:03:33
|
Hi all,i have an SP with a nasty select that take me alot of time as i need to do it twice as followUpdate table1Set col1 = select x from table2Update table1Set col2 = select y from table2is there any possible that i will do it with only one select or one set instead of twice as this is realy a nasty select qry which take alot of time.thanks,Linda. |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-01 : 17:20:55
|
Probably need to see the "nasty select" in full, because I doubt you can be doingUpdate table1Set col1 = select x from table2as that would, presumably, try to set "col1" to multiple rows from table2.Guessing:You might be able to do something like:UPDATE USET col1 = T2.foo, col2 = T2.barFROM Table1 AS U JOIN Table2 as T2 ON T2.ID = U.ID possible with some CASE stuff or a Nested-Aggregating-Sub-selectKristen |
 |
|
linda9898
Starting Member
28 Posts |
Posted - 2007-10-02 : 04:51:22
|
hi kristen, thanks again ... |
 |
|
|
|
|