[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Run a command line in SQL job-

Posted on 2008-11-10
4
Medium Priority
?
899 Views
Last Modified: 2012-05-05
I am running a command line in a SQL job,

rmdir /s \\vmpro_server\CDBURNER\PreviousDay

But the problem is, is that it ask "are you sure? (Y/N)" so what is happening is that the job just hangs and doesn't complete the command,

How do i get round this?

0
Comment
Question by:meteorelec
  • 2
4 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 22919889
you can run a command prompt command with xp_cmdshell system stored procedure.
this command requires sysadmin priviligages... usage i.e.

set @str = 'rmdir /s \\vmpro_server\CDBURNER\PreviousDay'
exec master..xp_cmdshell @str


Regards

0
 
LVL 2

Author Comment

by:meteorelec
ID: 22920047
I'm getting this error message when i execute xp_cmdshell:

Msg 50001, Level 1, State 50001
xpsql.cpp: Error 1314 from CreateProcessAsUser on line 636

0
 
LVL 11

Accepted Solution

by:
Louis01 earned 2000 total points
ID: 22920167
To force quiet mode:
rmdir /Q /S \\vmpro_server\CDBURNER\PreviousDay
 
0
 
LVL 26

Expert Comment

by:tigin44
ID: 22925408
did you try to run the xp_cmdshell with the sysadmin privillages? Otherwise you will get the error.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question