Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Rewriting 2000 Stored procedure in SQL Server 2008 R2 using Merge

$
0
0

Hello ,

I'm trying to convert a SQL 2000 stored procedure which Inserts/ updates a target table based on a few conditions , Merge is an obvious choice but have a few issues , there is no similar logic to insert and update .

Below is the stored procedure set up

1) Declare temp table to hold new records

2) Declare tmp table to hold changed records.

3) Insert into Target table with new records ( Here , they have a few inner and left joins )

4) update target table with certain conditions ( Here the have a condition of comparing target and source date and a PK , if they match then all records are updated)

My question is can merge is used to resolve the two scenarios , and is there a way to log number of records inserted / updated when using Merge. 

 I'd apprciate if any one can post a ref. I could use.

Thank you ,

Vishal.  



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>