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 |
|
rmi
Starting Member
6 Posts |
Posted - 2010-12-22 : 19:31:38
|
| I'm moving stuff from table1 and 2 to table3 with clause:---INSERT INTO Table3 (Col1, Col2, Col3, Col4)SELECT Table1.Col1,Table1.Col2,Table2.Col3,CEILING(Table1.Col3 * Table2.Col4) AS Col4FROM (Table1LEFT JOIN Table2ON Table1.Col2 = Table2.Col2)WHERE Table1.Col3 > 0---Table 2 holds multiple instances for each row in table 1.Now I need to create clause to update values in table3.col4 with similar clause as this one(to get table3.col4 correspond with updated values in table1.col3).I tried everything I came up with, without success..Any help appreciated.//rmi |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-12-22 : 22:45:08
|
| Can you provide some sample data and expected out to understand your requirement.Also do mention the version of SQL Server you are using. |
 |
|
|
rmi
Starting Member
6 Posts |
Posted - 2010-12-23 : 19:37:07
|
| I think I got it: UPDATE Table3 SET Col4 = CEILING(Table1.Col3 * Table2.Col4) FROM Table3 INNER JOIN (Table1 LEFT JOIN Table2 ON Table1.Col2 = Table2.Col2) ON Table3.Col1 = Table1.Col1 AND Table3.Col3 = Table2.Col3At least it gave correct results for now..//rmi |
 |
|
|
|
|
|