I'm having the same problem and Ive sybase client installed, so what path variables you're talking about here and how to change it?
the %PATH% allows you to do things like just type "notepad.exe" in the run command and let the operating system resolve the actual path to the executable for you behind the scenes....
but if you have the same executable in two or more folders that exist in the path, you are not guaranteed to call the one you were thinking
about...it's just the first one the OS finds.
if you go to a command window and type echo %PATH%
you might see a path to a sybase folder as well as to SQL server..so which bcp is it going to decide to use?
So to fix that you might need to explicitly put the entire path to the SQL server bcp, ie like this:
declare @sql varchar(4000),
--sample query: you would do the same to your existing bcp
--due to %path% issues, identify the full path to bcp
set @sql = 'C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\bcp.exe "SELECT TOP 5 * FROM SYSOBJECTS" queryout "c:\body.txt" -c -U"sa" -P"NotARealPassword"'
--export via bcp
insert into #results
EXEC master..xp_cmdshell @sql
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!