xp_cmdshell Alternative
An xp_cmdshell alternative is useful in an environment where its use is locked down. This article describes a simple alternative.It is a very powerful and useful extended stored procedure, and I often find a need for it in my SQL Agent jobs.
One such use might be to create a folder in a backup script. I need to run the following DOS command:
If it is not disabled, this could be called from within my job as follows:
However, use of this procedure is disabled by default in SQL Server 2005, and is deliberately disabled anyway in many organizations. My work-around is to create a SQL Agent job to run the command, give it time to run, then delete it again.
The following script does the job:
This creates a SQL Agent job, starts it, waits 5 seconds for it to complete, and then deletes it. I suggest you follow my naming convention of prefixing the job name with '_tmp_'. This means that if a job is created but fails to be deleted for some reason, you can see it easily at the top of the list of jobs.
Not found what you're looking for?
Use this search box. It is tuned for SQL Server searches. Try it and see!Do you have a question about SQL Server? Would you like to answer a question?
Go to the SQL FAQ to get started.

