|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, February 04, 2013 1:54 AM
Points: 180,
Visits: 241
|
|
I get this error message:
SQLState = HY000, NativeError = 0 Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file
if I try to run
EXEC master..xp_cmdshell bcp "select top 100 * from test.dbo.Table_1" queryout "c:\data.txt" -c -Usa -Psa123 -SD-D-MIRS\SQLEXPRESS'
from Query Analyzer (or a store procedure).
If run the same command in cmd or run window (without EXEC and xp_cmdshell) I do not get any error and the content of the table is exported in the file I want...
If the exported file is on a local folder on the server everything is working fine even in Query Analyzer...
Thank Manas
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 01, 2012 7:08 AM
Points: 1,
Visits: 22
|
|
Make sure cmdshell is enabled.
The best way is to create a job and make sure the Job is running under the correct user which has the rights to read/write to the folder.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, March 10, 2011 6:49 AM
Points: 1,
Visits: 5
|
|
Hi,
I had the same scenario.
Check the sql server service, it should be running with permissions for the folder that you're extracting to.
I'm using SQL express 2008 R2 with a Local system account. It didn't work, because it was configured to use a Network Service.
Best regards, Chen
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 4:23 AM
Points: 15,
Visits: 175
|
|
I received a similar error message when running a bcp command from SSMS, however it ran ok from a command prompt.
The SQL Service Account didn't have write permissions to the output file location!
|
|
|
|