Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 how to update table with date from another table ?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jylland
Starting Member

27 Posts

Posted - 12/09/2013 :  16:38:20  Show Profile  Reply with Quote
can anybody help me ?

I have two tables (tableA) and (TableB) in the same database

I plan a scheduled task every monday, it will take data from tableA and update TableB with them.

there are only 3 id's in every table, and the id rows in both tables is 1, 2 and 3.

TableA

id name
1 kay
2 bo
3 john

NeXT monday

the scheduled most update TableB with the data from TableA

so TableB after the scheduled executed look like this

id name
1 kay
2 bo
3 john

In the week after tableA will be updated with 3 new names, and the scheduled will NeXT monday again update TableB with this 3 names.

So there are always only 3 names. and every monday the scheduled will run.

How can I make a sql statement to update tableB with the data from tableA ??

Edited by - jylland on 12/09/2013 16:39:23

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 12/09/2013 :  18:47:42  Show Profile  Reply with Quote

update b
set    name = a.name
from   tablea a inner join tableb b on a.id = b.id



KH
Time is always against us

Go to Top of Page

jylland
Starting Member

27 Posts

Posted - 12/10/2013 :  12:47:53  Show Profile  Reply with Quote
great
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000