What To Do When the Import and Export Wizard Fails (Part I)

  • Actually, one of the native Job Types is an Operating System Command (CmdExec), which can be used in any step of a job. I've used xp_cmdShell many times in this situation by dynamically building my command-line string and then executing it using xp_cmdShell in a TSQL step.

    Another alternative that combines the best of both worlds is PowerShell. Powershell is another Job Type and can execute commands directly from the job step, or alternatively scripts can be invoked from a job step using the CmdExec option and the PowerShell.exe. The advantage of PowerShell is that you have the sqlps cmdlet which makes the whole SMO object model available. PowerShell scripts can also invoke command-line scripts and commands with the Invoke-Command cmdlet. By combining these two powerful cmdlets there isn't anything you can't do inside or outside of a SQL Job involving SQL Server.

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply