|
I want to implement merge statement in sql server 2005,since merge stmtn cannot be used in sql 2005. so i have to do a insert update and delete. I have two tables for eg
(comments are locked)
|
|
It's a two part issue - first, update the records that exist, and then insert the records that don't exist. Assuming R.No is the unique field, then something similar to the following should work: (untried and untested) There are other ways, of course... You'll probably want to wrap those two statements in a
(comments are locked)
|
|
This is true that there is no merge statement in SQL Server 2005, so you have to use 3 statements to do the work. It is best to do the update first because if insert is performed before update then the newly inserted records will also become a subject of the update, and while it does not do any harm, it is clearly a waste of resources. Since from the question definition it is not possoble to figure out which columns need to be updated and which are used for matching, I will assume that the column named R.No (I will call it R_No in the script below) is the key and the names columns are a subject of an update statement Oleg
(comments are locked)
|

