qt8gt0bxhw|20009F4EEE83|RyanMain|subtext_Content|Text|0xfbff360100000000b100000001001500
A co-worker pointed out to me something cool that is coming in SQL 2008. A new keyword for MERGE has been introduced. This new type of statement reduces some of the tedious work you typically do when adding data to a table in SQL. As things are now, you will check for the existence of a row, and then proceed to update the matched row if it exists, or insert the new data if the matching row did not exist. The new MERGE keyword allows you to do this all in a single statement.
This new MERGE statement reduces the following pseudo code:
/*
-- save parent table data
If Data Indentifier found in Parent Data Table
Update Data
Else
Insert Data
End
-- save child table data
Delete from Child Data Table all items not in Data
Update Child Data Table with all items in Data
Insert into Child Data Table all new items in Data
*/
To the following:
/*
-- save parent table data
MERGE Data to Parent Data Table
-- save child table data
MERGE Data to Chid Data Table
*/