A quick introduction to the new Merge Keyword in SQL 2008
<ul><li>Basic logic behind the Merge Keyword </li></ul><ul><li>Breakdown the Syntax </li></ul><ul><li>Lets see it in actio...
<ul><li>Senior Systems Designer for Cybner Computer Solutions who specialise in Microsoft Dynamics CRM Implementation & In...
<ul><li>Basic Upsert process </li></ul><ul><ul><li>Insert New Rows </li></ul></ul><ul><ul><li>Update Existing Rows </li></...
<ul><li>[ WITH <common_table_expression> [,...n] ]  </li></ul><ul><li>MERGE  </li></ul><ul><li>[ TOP ( expression ) [ PERC...
<ul><li>MERGE DESTINATION </li></ul><ul><li>USING  (This Source Data) ON this join </li></ul><ul><li>When  Matched  (exist...
<ul><li>Solves some of the complex problems with populating a data warehouse </li></ul><ul><li>No knowledge of SSIS is nee...
<ul><li>Over to you… </li></ul>
<ul><li>Best Resources for SQL 2008 resources: </li></ul><ul><ul><li>Google!!! Search what you are trying to do </li></ul>...
Upcoming SlideShare
Loading in …5
×

Merge In Sql 2008

2,180 views
2,099 views

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,180
On SlideShare
0
From Embeds
0
Number of Embeds
72
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • ETL – Extraction, Transformation &amp; Loading of data
  • Merge In Sql 2008

    1. 1. A quick introduction to the new Merge Keyword in SQL 2008
    2. 2. <ul><li>Basic logic behind the Merge Keyword </li></ul><ul><li>Breakdown the Syntax </li></ul><ul><li>Lets see it in action </li></ul><ul><li>Q & A </li></ul><ul><li>Next Steps </li></ul>
    3. 3. <ul><li>Senior Systems Designer for Cybner Computer Solutions who specialise in Microsoft Dynamics CRM Implementation & Integration </li></ul><ul><li>> 10 Years experience in the IT industry </li></ul>
    4. 4. <ul><li>Basic Upsert process </li></ul><ul><ul><li>Insert New Rows </li></ul></ul><ul><ul><li>Update Existing Rows </li></ul></ul><ul><ul><li>Delete removed Rows </li></ul></ul>
    5. 5. <ul><li>[ WITH <common_table_expression> [,...n] ] </li></ul><ul><li>MERGE </li></ul><ul><li>[ TOP ( expression ) [ PERCENT ] ] </li></ul><ul><li>[ INTO ] target_table [ [ AS ] table_alias ] </li></ul><ul><li>[ WITH ( <merge_hint> ) ] </li></ul><ul><li>USING <table_source> </li></ul><ul><li>ON <search_condition> </li></ul><ul><li>[ WHEN MATCHED [ AND <search_condition> ]         THEN <merge_matched> ] </li></ul><ul><li>[ WHEN [TARGET] NOT MATCHED [ AND <search_condition> ]         THEN <merge_not_matched> ] </li></ul><ul><li>[ WHEN SOURCE NOT MATCHED [ AND <search_condition> ]         THEN <merge_ matched> ] </li></ul><ul><li><output_clause> </li></ul><ul><li>[ OPTION ( <query_hint> [ ,...n ] ) ] </li></ul><ul><li>; </li></ul>
    6. 6. <ul><li>MERGE DESTINATION </li></ul><ul><li>USING (This Source Data) ON this join </li></ul><ul><li>When Matched (exists in both tables) </li></ul><ul><li>Do Something – probably Update </li></ul><ul><li>When Not Matched (A new record) </li></ul><ul><li>Do Something like Insert </li></ul><ul><li>When Source Not Matched (Row has been deleted from source table) </li></ul><ul><li>Do Something like Delete from Destination </li></ul><ul><li>OUTPUT ; </li></ul>
    7. 7. <ul><li>Solves some of the complex problems with populating a data warehouse </li></ul><ul><li>No knowledge of SSIS is needed </li></ul><ul><li>Cleaner code </li></ul><ul><li>Easy way to log the results of the Merge statement </li></ul><ul><li>Makes it easier to create data warehouses which in turn can provide a basis for better business intelligence & analysis </li></ul>
    8. 8. <ul><li>Over to you… </li></ul>
    9. 9. <ul><li>Best Resources for SQL 2008 resources: </li></ul><ul><ul><li>Google!!! Search what you are trying to do </li></ul></ul><ul><ul><li>http://www.sqlservercentral.com/ </li></ul></ul><ul><ul><li>http://msdn.microsoft.com/en-us/library/bb522522(SQL.100).aspx </li></ul></ul><ul><ul><li>Download the latest CTP & Start Playing!! </li></ul></ul><ul><li>More info on me: </li></ul><ul><ul><li>http://blog.cybner.com.au/ </li></ul></ul><ul><ul><li>http://www.twitter.com/ceibner </li></ul></ul>

    ×