SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

Kristen
Test

United Kingdom
22431 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: http://support.microsoft.com/kb/262499

Edited by - Kristen on 01/11/2012 12:53:29
  Previous Topic Topic Next Topic  
 New 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.02 seconds. Powered By: Snitz Forums 2000