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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update querie

Author  Topic 

bigshot
Starting Member

5 Posts

Posted - 2007-08-07 : 04:50:40
I have two tables with identical structure such as
ID, product1, product2, product3, product4, product5

Table 1 is filled with 5 ID numbers, say 1,2,3,4,5 and NULL (ie nothing) for the products.

Table 2 is filled with 10 ID numbers, 1,2,3,4,5,6,7,8,9,10 and all product details filled in (doesnt matter what with).

I have to update Table 1 such that it basically becomes a copy of table 2 with all the details.

My question here is, can this be done with a single query or must you use an UPDATE query to first update the details of the ID numbers 1-5, and then an INSERT query to get the details of ID's 6-10 into table one?
I have tried the UPDATE query, and managed to get it to update with ID's 1-5 with the product details, but did not manage to get it to insert ID's 6-10 into table 1.
If it can be done with a single query, maybe post some syntax?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-07 : 04:57:49
you will need an insert and an update query. Unless you are using 2008. http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=87088


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

bigshot
Starting Member

5 Posts

Posted - 2007-08-07 : 05:04:59
nah, 2005 here, thanks.
Go to Top of Page
   

- Advertisement -