Sqlstate = S1000, Nativeerror = 0

I am getting this Error While I try to do BCP

SQLState = S1000, NativeError = 0

Error = [Microsoft][SQL Server Native Client 11.0]Unable to open BCP host data-file

This is my code:

DECLARE @dump_data1 varchar(500)

SET @dump_data1 =  'bcp "select * from IDcountries.dbo.IDs$" queryout "\\NetworkLocation\watchdog.xls" -c -S STRIVEDI\SQLEXPRESS -T'

EXEC xp_cmdshell @dump_data1

I do have all the rights on Network Drive.

This code perfectly works fine for destination of my local drive like C:\.

I also tried entering -U and -P options as well. But, no luck

Can someone please help me on this issue?

3

3 Answers

I also faced the same problem. This seems to be permission of the folder. Edit the Security Tab under Folder Properties and give Modify permission to the user account through which SQL Server services are running in the SQL Server. Normally this user account is named as MSSQLSERVER. This worked fine for me.

When you have to put file file like BCP result, or a backup in a remote drive, just map this drive into windows don´t work, it must be mapped on SQL Server to!, to do this, try some link like this:

exec xp_cmdshell 'net use p:\ \\Server\Folder\Folder\Folder\ /Domain\Login /Password'
0

This is usually due to file create/writing permissions on the output target folder. Try to output data to a local folder on your machine to test:

bcp DATABASE.SCHEMA.TABLE out C:\TEMP\filename.dat -T -S SERVER-NAME -n

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest