Tech·Ed North America /31/2018 4:35 PM

Slides:



Advertisements
Similar presentations
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
 Pablo Castro Software Architect Microsoft Corporation TL08.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Gavin Russell-Rockliff BI Technical Specialist Microsoft BIN202.
Warren Stevens-Baytopp Director YoungBlood Consultants Session Code BIN303.

Scott Morrison Program Manager Microsoft Corporation Session Code: WUX308.
MIX 09 4/17/2018 4:41 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
How We Do Language Design at Microsoft (C#, Visual Basic, F#)
6/26/2018 9:02 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
9/11/2018 5:53 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Tech·Ed North America /14/2018 7:13 PM
Tech·Ed North America /15/2018 3:31 AM
Возможности Excel 2010, о которых следует знать
Optimizing Microsoft SQL Server 2008 Applications Using Table Valued Parameters, XML, and MERGE
Microsoft Visual Studio IDE Futures
9/22/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Sysinternals Tutorials
Tech·Ed North America /21/2018 6:42 PM
11/22/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Jason Zander Unplugged
Title of Presentation 12/2/2018 3:48 PM
12/5/2018 3:24 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Tech·Ed North America /5/2018 6:43 PM
Tech·Ed North America /7/2018 2:51 PM
The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA
12/27/ :01 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Authoring for Microsoft Silverlight 4 with Microsoft Expression Blend
Tech Ed North America /1/ :36 AM Required Slide
Tech·Ed North America /2/2019 4:47 PM
TechEd /15/2019 8:08 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Tech·Ed North America /17/2019 1:47 AM
1/17/2019 9:05 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Tech·Ed North America /17/2019 6:01 PM
TechEd /18/2019 2:43 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Microsoft SharePoint Conference 2009 Jon Flanders
Tech·Ed North America /22/2019 7:40 PM
Building Silverlight Apps with RIA Services
Building SaaS Solutions on Windows Azure
Tech Ed North America /12/2019 6:45 AM Required Slide
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
A Lap Around Internet Explorer 9 For Developers
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
TechEd /28/2019 7:58 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
2010 Microsoft BI Conference
WINDOWS AZURE A LAP AROUND PLATFORM THE Steve Marx
Tech·Ed North America /25/ :53 PM
Hack-proofing your Clients using Windows 7 Security!
Шитманов Дархан Қаражанұлы Тарих пәнінің
Lap Around the Windows Azure Platform
Code First Development in Microsoft ADO.NET Entity Framework 4.1
Building BI applications using PowerPivot for Excel
Title of Presentation 5/24/2019 1:26 PM
Tech·Ed North America /6/2019 7:10 PM
Tech·Ed North America /17/2019 4:14 PM
Tech·Ed North America /7/2019 2:30 PM
What’s New in Visual Studio 2012 for Web Developers
Presentation transcript:

Tech·Ed North America 2009 7/31/2018 4:35 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Tech·Ed  North America 2009 7/31/2018 4:35 PM Optimizing Microsoft SQL Server 2008 Applications Using Table Valued Parameters, XML, and MERGE Tobias Ternstrom Program Mgr., SQL Server Engine Microsoft Corporation DAT 320 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Agenda Passing a set of data to SQL Server 7/31/2018 4:35 PM Agenda Passing a set of data to SQL Server Adding MERGE to the equation © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Passing a Set of Data to SQL Server 7/31/2018 4:35 PM Passing a Set of Data to SQL Server N rows = N executed statements N rows = 1 executed statement © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Passing a Set of Data to SQL Server 7/31/2018 4:35 PM Passing a Set of Data to SQL Server N rows = N executed statements One client server roundtrip per execution All executions in one batch © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Passing a Set of Data to SQL Server 7/31/2018 4:35 PM Passing a Set of Data to SQL Server N rows = 1 executed statement Pass the data as a delimited list Pass the data as XML Pass the data as Table Valued Parameter Other options Managed bulk copy to a table Pass data as separate arguments (current limit is 2,100) © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7/31/2018 4:35 PM Examples In the examples, we will be passing a set of items to the database for storage Example – “Store the following 1,000 items” Examples we’ll use: Stored Procedures C# & ADO.NET © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Pass the Data as a Delimited List // C# cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Test.spDelimitedString"; cmd.Parameters.AddWithValue("@Values", @"…|…|… …|…|… …|…|…"); cmd.Execute…; -- What happens on the server? EXEC Test.spDelimitedString @Values = '…|…|… …|…|…';

Pass the Data as a Delimited List 7/31/2018 4:35 PM Pass the Data as a Delimited List To get the best performance, we need to use a SQLCLR Table Valued Function Pros: Performance is good No exposure to SQL Injection Cons: Requires SQLCLR to be enabled on the instance The set of data is not strongly typed Cumbersome implementation Can be simplified by creating one TVF per “list type” © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Pass the Data as XML // C# cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Test.spXML"; cmd.Parameters.AddWithValue("@Values", doc.OuterXml); cmd.Execute…; -- What happens on the server?: EXEC Test.spXML @Values = N'<Orders><Order…

Pass the Data as XML Pros Cons 7/31/2018 4:35 PM Pass the Data as XML Pros Strongly typed (if you use an XML Schema Collection) Performance is OK No exposure to SQL Injection A very good option if your data is already XML! Great flexibility; remember XML allows for hierarchies Cons Performance is good but not the best Requires knowledge about XML Less cumbersome than the delimited list but still somewhat cumbersome © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Pass the Data as a Table Valued Parameter // C# cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Test.spTVP"; var p = cmd.Parameters.Add("@Values", SqlDbType.Structured); p.TypeName = "Test.OrderTableType"; p.Value = dataTable; cmd.Execute…; -- What happens on the server?: DECLARE @Values Test.OrderTableType; INSERT @Values … EXEC Test.spTVP @Values = @Values;

Pass the Data as Table Valued Parameter 7/31/2018 4:35 PM Pass the Data as Table Valued Parameter Pros Strongly typed No exposure to SQL Injection Performance is great! Very easy to use, both on client and server side Cons Less flexible than XML; may require you to pass multiple TVPs where one XML parameter would have been enough Allows for streaming but only to the server © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Pass the Data as a Table Valued Parameter  Streaming // C# class MyStreamingTvp : IEnumerable<SqlDataRecord> { … } … cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Test.spTVP"; var p = cmd.Parameters.Add("@Values", SqlDbType.Structured); p.TypeName = "Test.OrderTableType"; p.Value = new MyStreamingTvp(…); cmd.Execute…; -- What happens on the server?: DECLARE @Values Test.OrderTableType; INSERT @Values … EXEC Test.spTVP @Values = @Values;

Pass the Data as a Table Valued Parameter  Streaming 7/31/2018 4:35 PM Pass the Data as a Table Valued Parameter  Streaming Pros No need for staging the data in memory on the client side Cons Doesn’t stream all the way, stages the data on the server side Requires a type to handle the streaming © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

A Few More Words on Streaming 7/31/2018 4:35 PM A Few More Words on Streaming If you stream, how “far” do you stream? N rows = N client server round trips & N proc. executions Streams “all” the way to the destination table Streaming TVP Streams from client to just before the procedure begins execution, i.e., stages the data on the server side The rest Stages the data both on the client and server side Any solution can implement streaming “manually” © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

What Happens? And What About Performance? 7/31/2018 4:35 PM What Happens? And What About Performance? Initial parsing of the data on the server Querying the data Insert the data into a table © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

1. Initial Parsing on the Server

1. Initial Parsing on the Server

2. Querying the Data

2. Querying the Data

3. Insert the Arguments into a Table

3. Insert the Data into a Table

Agenda Passing a set of data to SQL Server 7/31/2018 4:35 PM Agenda Passing a set of data to SQL Server Adding MERGE to the equation © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Adding MERGE to the Equation Also referred to as UPSERT Allows for inserting, updating and deleting data in one statement It is part of ANSI …with one addition!

Adding MERGE to the Equation Events MATCHED NOT MATCHED NOT MATCHED BY SOURCE Type of event $action

Adding MERGE to the Equation MERGE Test.Orders AS o USING @Values AS v ON v.OrderId = o.OrderId WHEN MATCHED THEN UPDATE SET CustomerId = v.CustomerId ,OrderDate = v.OrderDate ,DueDate = v.DueDate WHEN NOT MATCHED BY SOURCE THEN DELETE WHEN NOT MATCHED THEN INSERT (OrderId, CustomerId, OrderDate) VALUES(v.OrderId, v.CustomerId, v.OrderDate);

question & answer

Resources Required Slide Speakers, www.microsoft.com/teched TechEd 2009 is not producing a DVD. Please announce that attendees can access session recordings at TechEd Online. Resources www.microsoft.com/teched Sessions On-Demand & Community www.microsoft.com/learning Microsoft Certification & Training Resources http://microsoft.com/technet Resources for IT Professionals http://microsoft.com/msdn Resources for Developers www.microsoft.com/learning Microsoft Certification and Training Resources

Related Content Required Slide Speakers, please list the Breakout Sessions, TLC Interactive Theaters and Labs that are related to your session. Related Content DAT313 Inside T-SQL: Enhancements, Techniques, Tips & Tricks DAT305 Best Practices for Exception Handling and Defensive Programming in Microsoft SQL Server DAT04-INT Using the HIERARCHYID Datatype in Microsoft SQL Server 2008 to Maintain and Query Hierarchies 300 - Advanced, Database Platform, Developer Tools, Languages and Frameworks, Hands-on Lab, Middle Tier Platform and Tools

SQL Server Community Resources Connect: Local Chapters, Special Interest Groups, Online Community Share: PASSPort Social Networking, Community Connection Event Learn: PASS Summit Annual Conference, Technical Articles, Webcasts More about the PASS organization www.sqlpass.org/ The Professional Association for SQL Server (PASS) is an independent, not-for-profit association, dedicated to supporting, educating, and promoting the Microsoft SQL Server community. Become a FREE PASS Member: www.sqlpass.org/RegisterforSQLPASS.aspx Learn more about the PASS organization www.sqlpass.org/ Additional Community Resources SQL Server Community Center www.microsoft.com/sqlserver/2008/en/us/community-center.aspx TechNet Community for IT Professionals http://technet.microsoft.com/en-us/sqlserver/bb671048.aspx Developer Center http://msdn.microsoft.com/en-us/sqlserver/bb671064.aspx SQL Server 2008 Learning Portal http://www.microsoft.com/learning/sql/2008/default.mspx

Additional Resources External Resources Team Forum: Speaker URL #2 Other: Speaker URL #3 External Resources TVPs http://msdn.microsoft.com/en-us/library/bb510489.aspx MERGE http://technet.microsoft.com/en-us/library/bb510625.aspx SQL Server 2008 Business Value Calculator: www.moresqlserver.com

Complete an evaluation on CommNet and enter to win! Required Slide Complete an evaluation on CommNet and enter to win!

Required Slide 7/31/2018 4:35 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.