I wrote a stored procedure in the following format:
ALTER PROCEDURE usp_data_migration (@sourceDatabase varchar(50), @sourceTable varchar(50), @targetDatabase varchar(50), @targetTable varchar(50), @finaloutput varchar(max) output) AS BEGIN
Then I execute the procedure:
DECLARE @finaloutput1 varchar(300) EXEC usp_data_migration 'Yousuf', 'emp', '[City Branch]', 'emp_tgt', @finaloutput1 output SELECT @finaloutput1
Following this path, I am not making the right conclusion.
When I execute this path:
DECLARE @finaloutput1 varchar(300) EXEC usp_data_migration @sourceDatabase = 'Yousuf', @sourceTable = 'emp', @targetDatabase = '[City Branch]', @targetTable = 'emp_tgt', @finaloutput1 output SELECT @finaloutput1
I get an error message:
Msg 119, Level 15, State 1, Line 41
You must pass parameter number 5 and the following parameters as "@name = value". After using the form "@name = value", all subsequent parameters must be passed in the form "@name = value".
And if I delete my output parameter and execute the procedure, I get the desired result, but I can not get the result as output.
EXEC usp_data_migration @sourceDatabase = 'Yousuf', @sourceTable = 'emp', @targetDatabase = '[City Branch]', @targetTable = 'emp_tgt'
What should I do?
Thanks in advance.