![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is it possible to use sql to execute a batch file? I would like to execute the following "C:\BTW\bartend.exe /f=C:\BTW\Toolbox\Formats \carnum.btw /p", 6 Thanks, Matt |
#3
| |||
| |||
|
|
You can look at xp_cmdshell. Note that no program run that way can open any sort of window, or prompt the "user" for anything at all. You may also want to look into running it as a job. Roy Harvey Beacon Falls, CT On Thu, 09 Aug 2007 15:44:36 -0000, mcolson <mcolson1... (AT) gmail (DOT) com wrote: Is it possible to use sql to execute a batch file? I would like to execute the following "C:\BTW\bartend.exe /f=C:\BTW\Toolbox\Formats \carnum.btw /p", 6 Thanks, Matt |
#4
| |||
| |||
|
|
When I use the xp_cmdshell to try and run the bat file, i get an output saying access denied. It should be noted that I am using sql server 2005 express. Is this why. When I try to copy the file to another location, i get 0 copied. I am able to dir the directory just fine. |
#5
| |||
| |||
|
|
On Thu, 09 Aug 2007 21:23:07 -0000, mcolson <mcolson1... (AT) gmail (DOT) com wrote: When I use the xp_cmdshell to try and run the bat file, i get an output saying access denied. It should be noted that I am using sql server 2005 express. Is this why. When I try to copy the file to another location, i get 0 copied. I am able to dir the directory just fine. I am not familiar with Express, but I don't think it is any different in this area. What is important to remember is that any command run through xp_cmdshell is running under the account designated for that, and that is the account that needs the permissions. Running xp_cmdshell 'set' and inspecting the results should tell you the account being used. While it does not appear to be your problem it is worth noting also that xp_cmdshell runs in a context without any mapped drives, so any files on a network drive must be referenced using a UNC path of the form \\servername\sharename\folder... Roy Harvey Beacon Falls, CT |
#6
| |||
| |||
|
|
Sql is setup as a Network Service. I could change it to a local user, but would prefer not to. I'm trying to setup a credentials named "Matt". In here I have entered the login and password for an accepted user of the file. How do I tell the stored procedure to use this credential when I am running the bath file? |
#7
| |||
| |||
|
|
Sql is setup as a Network Service. I could change it to a local user, but would prefer not to. I'm trying to setup a credentials named "Matt". In here I have entered the login and password for an accepted user of the file. How do I tell the stored procedure to use this credential when I am running the bath file? |
![]() |
| Thread Tools | |
| Display Modes | |
| |