September 27, 2016 at 10:58 am
I'm trying to run the following command as part of a batch file:
sqlcmd -S %_var1% -d %_var2% -Q "DECLARE @status varchar(100) exec dbo.sp_RunSQLAgentJob @job_name = 'Process OpenToBuyWhatIfAnalysis', @job_stat_desc = @status OUTPUT PRINT @status;"
I receive an error "unexpected argument." What is this and why?
September 27, 2016 at 1:48 pm
I could be wrong, but I think you are missing a few ;
I think the command should be:
sqlcmd -S %_var1% -d %_var2% -Q "DECLARE @status varchar(100); exec dbo.sp_RunSQLAgentJob @job_name = 'Process OpenToBuyWhatIfAnalysis', @job_stat_desc = @status OUTPUT; PRINT @status;"
NOTE the ; after OUTPUT and after varchar(100).
I could be mistaken, but I am pretty sure you need some form of statement terminators in there.
failing that, what are the values of %_var1% and %_var2%? Maybe those have some unhappy values in them?
Can you run that single line outside of the batch file without errors?
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
November 10, 2016 at 3:06 am
Yes. I had almost the same mistakes few weeks ago ) Asked for help from Essay pedia but they din't help me properly so I suggest you just search info in the web or ask here.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply