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.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 xp_cmdshell can't find bcp

Author  Topic 

DGMelkin
Starting Member

24 Posts

Posted - 2002-07-31 : 17:24:31
I think this is more of an operating system issue, but we're running into production problems where the stored procedure can no longer find bcp when executing xp_cmdshell.

EXEC xp_cmdshell 'bcp'
returns:
'bcp' is not recognized as an internal or external command,
operable program or batch file.

If you supply the path for bcp, it works. There's no problem when you type bcp from a command window. When we tried resetting the environment variables on the machine and then restarting SQL services, but that didn't seem to work. Unfortunately, the bcp command is being passed in through the application and we're trying to avoid rewriting it. And OPENROWSET thinks the first row is the column header, so we can't use that.

What do we need to do to fix it? Does anyone know why does it happens?

Thanks in advance!
--D


jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-07-31 : 17:38:25
log in to the server using the account SQL server runs under and check the enviroment variables (SET at command prompt) make sure it's got a bit in PATH for C:\Program Files\Microsoft SQL Server\80\Tools\Binn (this is the default path for SQl 2000)


HTH
Jasper Smith
Go to Top of Page

DGMelkin
Starting Member

24 Posts

Posted - 2002-07-31 : 18:05:02
We did. It's actually a 7.0 server. The path where bcp resides was there.

Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-01 : 04:10:23
And I guess that when you are logged in as the SQL server service account that issuing bcp at a normal command prompt has the same problem ? IF its definately in the PATH variable and the server has been rebooted then it seems you might have to use the whole path.



HTH
Jasper Smith
Go to Top of Page

DGMelkin
Starting Member

24 Posts

Posted - 2002-08-01 : 08:15:20
As I said, we don't have that problem from the command prompt. The path for the system has the location of the directory for bcp. Shouldn't that work regardless of the user?

-- D

Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-01 : 08:39:19
So it works from a cmd prompt when you are logged into the server as the SQL Service account ?


HTH
Jasper Smith
Go to Top of Page
   

- Advertisement -