Question
November 21, 2007 at 11:08 AM
fahim kanji

Set-based update query

by fahim kanji . Updated 18 years, 9 months ago

In SQL SERVER 2005 I have 2 tables as follows:
table1_old
{
id smallint (PK)
status bit
}
table1_new
{
id smallint (pk)
status bit
}

table1_old’s records are, in effect, a subset of table1_new’s records. I want to update the status flag for each record in table1_new that’s in table1_old with the status value in table1_old for the associated record.

Obviously you can use a cursor, but i’d rather learn how to do it in a set-based query (I think it’s possible, but I’m not sure how to write the TSQL Statement)

Can someone show me how to do it and if there are good resources online that teach set-based querying principles and techniques, could you post the link?

Thank you very much,

Fahim.

This discussion is locked

All Comments