Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-01-09 : 10:06:36
|
| Ralph writes "i'm trying to use xp_cmdshell to execute a command using bcp within a stored procedure.the command i'm trying to execute runs fine from the command line but when i try to run it within the stored procedure, i get the following error:"'bcp' is not recognized as an internal or external command,operable program or batch file."I get a similar error trying other methods like osql.i've checked the PATH variable and it contains the directory in which the bcp.exe program sits.Here's my code to examine.select @bcpCommand = 'bcp "database..table" out "c:\file.txt" -U user -P pass -c 'EXEC master.dbo.xp_cmdshell @bcpCommandThanks in advance." |
|
|
efelito
Constraint Violating Yak Guru
478 Posts |
Posted - 2002-01-09 : 16:44:35
|
| Specify the entire path and it should work fine. The PATH variable is different for the service account that sql uses to run the command on the OS than when you are logged in as yourself. You should never rely on path variables to run your executeables. Try your command like this.select @bcpCommand = 'c:\mssql7\binn\bcp.exe "database..table" out "c:\file.txt" -U user -P pass -c 'EXEC master.dbo.xp_cmdshell @bcpCommandJeff BanschbachConsultant, MCDBA |
 |
|
|
muhiar
Starting Member
37 Posts |
Posted - 2006-04-27 : 11:44:20
|
| hii have tried your solution but it does not workit keeps telling me that 'bcp' is not recognized as an internal or external command,operable program or batch file."although the same command works from the command prompt when i work from the c:\Program File\microsoft SQL Server\80>> bcp |
 |
|
|
|
|
|