The sum of all SQL Server matter that exist,
and the space in which all SQL Server events
occur or could occur.
Welcome to SQL Server Universe.com Sign in | Join | Help
in
Home SS SLUG Forums Articles Photos Downloads

T-SQL Enhancements in SQL Server 2008 - Part 1

Last post 04-05-2008, 15:41 by Dinesh Asanka. 2 replies.
Sort Posts: Previous
  • T-SQL Enhancements in SQL Server 2008 - Part 1

     03-30-2008, 8:47

    • Joined on 11-22-2006
    • Colombo, Sri Lanka
    • Posts 97
    • Points 0
    • Top 10 Contributor
      Male
    This thread is for the article T-SQL Enhancements in SQL Server 2008 Part I by Dinesh Asanka. Rate it and give your feedback.

    How would you rate this article?

    • Excellent (0%)
    • Good (100%)
    • Average (0%)
    • Fair (0%)
    • Poor (0%)
    • Total Votes: 2
  • Re: T-SQL Enhancements in SQL Server 2008

     04-05-2008, 12:07

    • Joined on 04-05-2008
    • Posts 1
    • Points 0
    • Top 75 Contributor

    Hi Dinesh,

    I read your article and very impressed with the new features in SQL Server 2008. But, I am little bit confused with MERGE statement execution.

    Let me explain:

    You created two tables named tblSource and tblTarget. Both the tables have Identity columns.

    In the second MERGE example which includes DELETE option. tblSource has IDs 1,2 and 3 and initially tblTarget table has IDs 1,2,3 and 4 out of which 1 and 2 IDs are matching with tblSource table but not 3 and 4. MERGE statement updates the ID = 2 in tblTarget table then INSERT the ID = 3 again into tblTarget table. Now the ID in tblTarget table should be 5, because already ID 3 is existing in tblTarget table. DELETE option deletes the IDs 3 and 4 from tblTarget table. Finally tblTarget should have IDs 1,2 and 5, but your Final Target table has IDs 1, 2 and 3. how is that possible?

    Does the Identity columns fills the gaps in SQL Server 2008 or the precedence of the execution is different than what I am expecting?

    Can you please clarify my doubt?

    Regards,

    Ravi.

  • Re: T-SQL Enhancements in SQL Server 2008

     04-05-2008, 15:41

    • Joined on 03-26-2007
    • Colombo
    • Posts 21
    • Points 0
    • Top 10 Contributor
      Male

    Hi Ravi,

    Thanks for your comments. Is it possible you to paste your T-SQL script here.

    Thank You


    Blog: http://dineshasanka.spaces.live.com
View as RSS news feed in XML

(Best viewed with a resolution of more than 1024 * 768)

Powered by Community Server, by Telligent Systems