sql server - Calling stored procedure with OUTPUT parameter in dynamic SQL -
i calling stored procedure output
parameter using dynamic sql.
set @csql='exec '+@cname+'.dbo.uspndateget ''' +convert(varchar(10),@dtason,102)+''',''' +@cbr+''',''' +@clcode+''',''' +convert(varchar(10),@dtndate,102)+''' output' exec(@csql)
on executing script, following error.
cannot use
output
option when passing constant stored procedure.
without using dynamic sql, script gives me required result.
exec uspndateget @dtason,@cbr,@clcode,@dtndate output
you need pass parameters outside inside query.
here show generic case:
declare @sql nvarchar(max); declare @out1 nvarchar(10); declare @out2 nvarchar(10); declare @parmdef nvarchar(max); set @parmdef = ' @parm_out1 nvarchar(10) ' + ', @parm_out2 nvarchar(10) ' ; set @sql='exec myproc @parm_out1 output, @parm_out2 output ' exec sp_executesql @sql, @parmdef, @parm_out1 = @out1, @parm_out2 = @out2
Comments
Post a Comment