I am calling a stored procedure with 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 the script, I get following error.
Cannot use the
OUTPUT
option when passing a constant to a stored procedure.
Without using dynamic SQL, the script gives me the required result.
EXEC uspNDateGet @dtAsOn,@cBr,@cLCode,@dtNDate OUTPUT
You need to pass parameters from outside into the inside query.
Here I show you the generic case: