sql-serverscheduled-taskssqlcmdwindows-task-scheduler

Using sqlcmd.exe in windows task scheduler


I want to push data from one server to another using Task Scheduler and by sqlcmd. Here is the argument i use for

sqlcmd.exe :- -S "Server IP,Port No\SQLSERVER" -U username -P password -d 
database -Q "exec data_export" 

The server where I want to push uses a custom port.

Currently, I'm using data_export procedure manually. But I want to do it automatically using Task Scheduler.

enter image description here


Solution

  • Then your syntax should be something like this:

    sqlcmd -S SERVER\INSTANCE,PORT -U username -P password -d database -Q "exec data_export"
    

    Have you tried this?

    And one more thing, when you config this in the task scheduler, you need to write sqlcmd in the field "Program/Script" as shown in your image. And all the rest of the command should be set in the field "Add Arguments".