My contemplations and diurnal novelties are publicized here



— setting a variable from dynamic sql
Author Nigel Rivett

 

declare @i int

exec sp_executesql N’select @i = 999′, N’@i int output’, @i output

select @i

 

 

— setting output parameter from dynamic stored procedure call

 

declare @OutputParameter varchar(100) ,

        @error int ,

        @SPName varchar(128) ,

        @SPCall nvarchar(128) ,

        @rc int

select @SPCall = ‘exec ‘ + @SPName + ‘ @OutputParameter output’

exec @rc = sp_executesql @SPCall, N’@OutputParameter varchar(100) output’, @OutputParameter output

select @Error = @@error

 

reference: http://www.nigelrivett.net/SQLTsql/sp_executeSQL.html

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: