sql2012 - To execute an osql command

motioneye used Ask the Experts™
Not sure if the sql agent job will allow if I put the following  to execute osql command in  Operating System Command (CmdExec) Will the below work ??

osql -E -q "declare @rc int
EXEC @rc = osql -E -q usr_sp_reviewamounts"
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
osql is outdated. Use sqlcmd instead.

It makes no sense to define and assign the procs result value, when you don't return it.

Why do you want to call a procedure that way? Why not directly calling it with an T-SQL task?
Yes just for executing the stored procedure you dont need SQLCMD or OSQL if you are going to schedule the SP in SQL agent job.

Create a SQL agent job with TSQL step and only single line of code will be fine.

execute <databasename>.<schemaName>.usr_sp_reviewamounts

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial