By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,363 Members | 2,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,363 IT Pros & Developers. It's quick & easy.

Dataset

OuTCasT
100+
P: 374
I would like to know if its possible to select data from 2 or more tables with an inner join into one dataTable ???
then update that information and save them back to the tables.
?
Apr 1 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
Yes.

Expand|Select|Wrap|Line Numbers
  1. select key1, table1.col1, table2.col2, space(5) as newcol
  2. into newtable
  3. from table1
  4. inner join table2 on table1.key1 = table2.key1
  5.  
  6. update newtable
  7. set newcol = newvalue
  8. where condition = true
  9.  
  10. update table1
  11. set somecolumn = newcol
  12. from newtable
  13. inner join table1.key1 = newtable.key1
  14.  
  15. drop table newtable
you may also use temporary table, so just place a "#" on the newtable name.

-- CK
Apr 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.