sql server – BCP error Unable to open BCP host data-file

sql server – BCP error Unable to open BCP host data-file

From the error I take, that the data file cannot be opened:

C:UsersSerge>BCP Testing.bdo.Exporttable out C:UsersSergeDesktopMyFile.txt -C -T

I think, you have to add a filename behind the Desktop. Desktop is an existing directory and cannot be opened as file …

And – btw – it might be necessary to add -S Servername

UPDATE

Found this here

Whenever I get this message, its because of one of three things:

1) The path/filename is incorrect (check your typing / spelling)

2) The file does not exist. (make sure the file is where you expect it
to be)

3) The file is already open by some other app. (close the other app to
release the file)

For 1) and 2) – remember that paths are relative to where bcp is
executing. Make sure that bcp.exe can access the file/path from its
context.

/Kenneth

If you are running BCP through xp_cmdshell, run the following–>
xp_cmdshell whoami;
GO
–Make sure whatever user value you get back has full access to the file in question

sql server – BCP error Unable to open BCP host data-file

Run: EXEC master..xp_cmdshell DIR C:UsersSergeDesktop, this will show if you have access to the path.

Remember if you are accessing SQL remotely or over a network, the output ie. C:UsersSergeDesktop will be the C drive on the SQL Server, not your remote PC you are working on.

Leave a Reply

Your email address will not be published.