MERGE in sql server 2008

MERGE in sql server 2008. Explain with an example

Merge statement allows a single statement for INSERT, DELETE and UPDATE a row that depends on a condition. The target table for certain operations is based on the results of join with a source table.

The following example illustrates the use of MERGE.
MERGE InventoryMaster AS invmstr
USING (SELECT InventoryID, Descr FROM NewInventory) AS src
ON invmstr. InventoryID = src. InventoryID
WHEN MATCHED THEN
        UPDATE SET invmstr.Descr = src.Descr
WHEN NOT MATCHED THEN
INSERT (InventoryID, Descr) VALUES (src. InventoryID, src.Descr);.
Steps to improve performance of a poor performing query
Steps to improve performance of a poor performing query - Maximum use of indexes, stored procures should be done, Avoid excessive use of complicated joins and cursors........
Deadlock and live lock. How will you go about resolving deadlocks?
Deadlock and live lock - A deadlock occurs when two or more processes waits for a resource that is acquired by or is under the control of another process.....
What is blocking and how would you troubleshoot it?
What is blocking and how would you troubleshoot it? - Blocking occurs when two or more rows are locked by one SQL connection and a second connection to the SQL server requires a conflicting on lock on those rows........
Post your comment