Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Syntax for OUTPUT parameter using sp_ExecuteSQL
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  


United Kingdom
22859 Posts

Posted - 01/11/2012 :  06:44:44  Show Profile  Reply with Quote
As its a FAQ here's an example:

DECLARE @MyOutputParameter int,
        @SomeID int

SELECT @SomeID = 1234

EXEC sp_ExecuteSQL N'SELECT @MyOutputParameter = MyColumn FROM MyTable WHERE MyID = @SomeID',
                   N'@MyOutputParameter int OUTPUT, @SomeID int',
                   @MyOutputParameter = @MyOutputParameter OUTPUT,
                   @SomeID = @SomeID

SELECT	[@MyOutputParameter]=@MyOutputParameter

Both OUTPUT parameters, in the call to sp_ExecuteSQL, are required

See also:

Edited by - Kristen on 01/11/2012 12:53:29
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000