• Home
  • All Articles
  • SQL Interview Q & A
  • Blog Stats
  • Contact
    • Resume
    • Performance
    • Community Rules
    • Copyright
  • Tools
    • Expressor
    • Pluralsight
    • Embarcadero
    • Manage Engine
    • Idera
    • Red Gate
    • SafePeak
  • SQL Books
    • SQL Interview Q & A
    • SQL Wait Stats
    • SQL Programming
  • >>Search<<

SQL Server Journey with SQL Authority

Personal Notes of Pinal Dave

Feeds:
Posts
Comments
« SQL SERVER – Denali – Executing Stored Procedure with Result Sets
SQL SERVER – CTAS – Create Table As SELECT – What is CTAS? »

SQL SERVER – Denali – Executing Stored Procedure with Result Sets

April 29, 2011 by pinaldave

After reading my earlier article SQL SERVER – Denali – Executing Stored Procedure with Result Sets, one of the readers asked if this new feature (syntax) support multiple resultset of the stored procedure? Very interesting question indeed as most of the stored procedures that I usually come across have more than one resultset. I quickly look up the syntax online and realize it can be done quite easily. If you are using the earlier method of the temp table inserting the value of the stored procedure by executing, then the it does not support multiple resultset.

This new capability of T-SQL can be really useful.

USE AdventureWorks2008R2
GO
CREATE PROCEDURE mySP1 (@ShiftID INT, @JobCandidateID INT)
AS
-- ResultSet 1
SELECT [ShiftID]
,[Name]
,[StartTime]
,[EndTime]
,[ModifiedDate]
FROM [HumanResources].[Shift]
WHERE [ShiftID] = @ShiftID
-- ResultSet 2
SELECT [JobCandidateID]
,[BusinessEntityID]
,[ModifiedDate]
FROM [HumanResources].[JobCandidate]
WHERE JobCandidateID = @JobCandidateID
GO
EXEC mySP1 @ShiftID = 2, @JobCandidateID = 5
WITH RESULT SETS
(
(
[ShiftID] TINYINT
,[Name] NVARCHAR(50)
,
[StartTime] DATETIME
,[EndTime] DATETIME
,[UpdateDate] DATETIME -- Notice Name Change
),
(
[JobCandidateID] INT
,[BusinessEntityID] INT
,[ModifiedDate] DATETIME
)
);

Here is quick question to all of you – do you see how this feature can help resolve few of the T-SQL issues faced in earlier version? Your opinion really matters.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Share:

Like this:

Like
2 bloggers like this post.
  • Gaurang Patel
  • Vishal

Posted in PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology | Leave a Comment

  • free community tool

    Expressor
    pluralsight
    Red-Gate
    ManageEngine
    Idera
    red-gate
    SafePeak
    Koenig
  • About Pinal Dave

    Pinal Dave is a Microsoft Technology Evangelist (Database and BI). He has written over 2000 articles on the subject on his blog at http://blog.sqlauthority.com. Along with 8+ years of hands on experience he holds a Masters of Science degree and a number of certifications, including MCTS, MCDBA and MCAD (.NET). He is co-author of three SQL Server books - SQL Server Programming, SQL Wait Stats and SQL Server Interview Questions and Answers. Prior to joining Microsoft he was awarded Microsoft MVP award for three continuous years for his contribution in community.
    LinkedIn - Pinal Dave Twitter - Pinal Dave facebook
    Feed Email

    Follow @pinaldave Send +Pinal Dave an email at pinal@sqlauthority.com
  • Blog Stats

    • 37,516,901 (37 Million+)
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 17,045 other followers

  • Next Office Hours

    Feb 22, 2012 1130 Indian Standard Time (0600 GMT)
  • Books I Authored

    . Amazon|Flipkart|Kindle

    . Amazon|Flipkart|Kindle

    Amazon|Flipkart|Kindle
  • SQLAuthority Links

    Subscribe to Newsletter
    My Homepage
    Windows Live Blog
           --------------------
    Top Downloads
       PDF Downloads
       Script Downloads

    Script Bank
       Favorite Scripts
       All Scripts - 1
       All Scripts - 2
       All Scripts - 3

    Top Articles
       Best Articles
       Favorite Articles - 1
       Favorite Articles - 2
           --------------------
    > SQL Interview Q & A <
    SQL Coding Standards
    SQL FAQ Download
           --------------------
    Jobs @ SQLAuthority
    Bookmark and Share
    AddThis Feed Button
  • About Nupur Dave

    Nupur Dave loves technology simply because it makes life more convenient. She is devoted to technology because it touches our heart makes our daily lives easier. Among the many technological programs she uses and embraces Windows Live most because she can do lots of things with ease – from photo management to movies; business emails to personal social media connections.

  • Disclaimer

    This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet/ BOL. My employer do not endorse any tools, applications, books, or concepts mentioned on the blog. I have documented my personal experience on this blog.

    • Home
    • All Articles
    • SQL Interview Q & A
    • Blog Stats
    • Contact
      • Resume
      • Performance
      • Community Rules
      • Copyright
    • Tools
      • Expressor
      • Pluralsight
      • Embarcadero
      • Manage Engine
      • Idera
      • Red Gate
      • SafePeak
    • SQL Books
      • SQL Interview Q & A
      • SQL Wait Stats
      • SQL Programming
    • >>Search<<
  • Categories

    • About Me (145)
    • Best Practices (143)
    • Business Intelligence (37)
    • CodeProject (10)
    • Data Warehousing (50)
    • Database (324)
    • DBA (137)
    • Joes 2 Pros (47)
    • Pinal Dave (1580)
    • Software Development (69)
    • SQL Azure (15)
    • SQL Backup and Restore (79)
    • SQL Coding Standards (21)
    • SQL Constraint and Keys (57)
    • SQL Cursor (28)
    • SQL Data Storage (59)
    • SQL DateTime (47)
    • SQL DMV (33)
    • SQL Documentation (105)
    • SQL Download (311)
    • SQL Error Messages (163)
    • SQL Function (161)
    • SQL Humor (29)
    • SQL in Sixty Seconds (3)
    • SQL Index (155)
    • SQL Interview Questions and Answers (139)
    • SQL Joins (78)
    • SQL Optimization (152)
    • SQL PASS (20)
    • SQL Performance (340)
    • SQL Puzzle (98)
    • SQL Scripts (866)
    • SQL Security (132)
    • SQL Server DBCC (42)
    • SQL Server Management Studio (44)
    • SQL Service Pack (13)
    • SQL Stored Procedure (116)
    • SQL String (26)
    • SQL System Table (61)
    • SQL Trigger (24)
    • SQL User Group (57)
    • SQL Utility (154)
    • SQL View (26)
    • SQL Wait Stats (41)
    • SQL Wait Types (42)
    • SQL White Papers (67)
    • SQLAuthority (633)
      • SQL Training (19)
      • SQLAuthority Author Visit (141)
      • SQLAuthority Book Review (40)
      • SQLAuthority News (578)
      • SQLAuthority Website Review (42)
    • SQLServer (233)
    • Technology (2048)
      • PostADay (469)
      • SQL (2048)
      • SQL Authority (2048)
      • SQL Query (2048)
      • SQL Server (2046)
      • SQL Tips and Tricks (2048)
      • T SQL (2048)
    • Video (7)
  • Top 3 Commenters

      2251- Madhivanan
      474 - Imran Mohammed
      301 - Ramdas Jaya
  • Page copy protected against web site content infringement by Copyscape

Blog at WordPress.com. Fonts on this blog.

Theme: MistyLook by Sadish.


loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.