Ошибка sqlstate s1000

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 "\NetworkLocationwatchdog.xls" -c -S STRIVEDISQLEXPRESS -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?

marc_s's user avatar

marc_s

728k174 gold badges1327 silver badges1455 bronze badges

asked Oct 17, 2013 at 20:45

user2704062's user avatar

3

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.

Gwenc37's user avatar

Gwenc37

2,0647 gold badges18 silver badges22 bronze badges

answered Apr 24, 2014 at 7:01

Sanjeev Garg's user avatar

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:TEMPfilename.dat -T -S SERVER-NAME -n

answered Feb 2, 2022 at 15:14

GBGOLC's user avatar

GBGOLCGBGOLC

5208 silver badges7 bronze badges

I am trying to create a format file for use with bcp exporting and bcp importing.  I am actually just practicing to make sure I have this bcp stuff down before attempting to use it for copying a large database.  The command I am using is

!!bcp «OLDAdventureWorks2008R2.dbo.AWBuildVersion» format nul -f «c:OLDAdventureWorks2008R2_dbo_AWBuildVersion.xml» -x -q -N -T -S Netsql1SQL2008_APPS

The error I get when I run the above (in SSMS Query Editor running in SQLCMD mode) is:

SQLState = S1000, NativeError = 0

Error = [Microsoft] [SQL Native Client] Format File : Invalid Field Index

The format file «OLDAdventureWorks2008R2_dbo_AWBuildVersion.xml» gets created, but contains no data.

I don’t get this error for any other table in the OLDAdventureWorks2008R2 database, only this on (i.e. AWBuildVersion).  Note also that database OLDAdventureWorks2008R2 is a copy of AdventureWorks2008R2.

The other day one job started to fail every time it ran. The error was

Server: FancyServerName 
Job: SomeJobName 
Step: Step 3) SomeStepName 
Message: Executed as user: SomeDomainSomeServiceAccount. Starting copy… SQLState = S1000, NativeError = 0 Error = [Microsoft][ODBC Driver 11 for SQL Server]I/O error while writing BCP data-file 19 rows copied. Network packet size (bytes): 4096 Clock Time (ms.) Total : 1 Average : (19000.00 rows per sec.). Process Exit Code 1. The step failed. 
Time: 2015-10-06 08:16:20

This was very interesting since the file we were writing had only 19 rows and this was very small, less than a kilobyte. So how do you investigate what the error is? It could be all kinds of things:

Permissions on the drive
Problems with the drive
Memory issues
Issue with a format file

If you do a search you will get all kinds of things back. However the first thing you need to run is the following


Here is what I saw after running xp_fixeddrives



drive      MB free
C             235644
D             1479234
E              10123
F              10123
G             10123
L              10123
S              117706
T              10123
Z              0


Take a look at the Z drive do you see that? The Z drive is full, there is no space left. It would be nice if the error message indicated that it couldn’t write to the file because there was no space left. In a production environment this should not happen because hopefully you have something in place that sends out an alert if the drive is 90% full.

So, if you ever get this error, first thing you have to do is if you have space left on the drive.

I also want to point out that the xp_fixeddrives stored procedure is undocumented so there is no guarantee it will be available in a future version of SQL Server.

I am trying to execute the below BCP query in my TEST Server, where BCP has a connection string to the production DB, so my destination folder is in my Test Server and I am getting an error, I think it’s a permission related issue.

DECLARE @str NVARCHAR(2000), @path NVARCHAR(200)='Z:SQL' , @TableName NVARCHAR(100)='tblUsers' Set @str = 'BCP IDB.dbo.'+@TableName+ ' OUT '+@path +''+@TableName+'.csv -c -t^| -T -S ProductionServerNameSQL2012' Exec xp_cmdshell @str

Print (@str) = BCP IDB.dbo.tblUsers OUT Z:SQLtblUsers.csv -c -t^| -T -S ProductionServerNameSQL2012

ERROR: output SQLState = S1000, NativeError = 0 Error =
[Microsoft][SQL Server Native Client 10.0]Unable to open BCP host
data-file NULL

I shared my Test Server folder to the Production User account. Also I have mapped the shared folder drive as a network share in production and run the below SQL statements:

EXEC XP_CMDSHELL 'net use Z: \TestServevrNameTest'

EXEC XP_CMDSHELL 'Dir Z:'

Still I am facing the same Issue.

Please guide me what steps are required to fix this permissions issue.

  • Remove From My Forums
  • Question

  • I am getting this error while importing data from a csv file to SQL azure table. I am new to this technology. So I am trying it out with some small
    no of records. I have very few records in my csv file and my Azure database table is empty right now.

     
    This is the structure of the table in SQL Azure:
     
    Create Table BCP
    (
    Id int identity(1,1)
    Value int,
    Name nvarchar(50),
     
    Constraint [pk_bcp] primMary key clustered([id] asc)
    ) on [primary]
    records I am trying to insert are as follows
     
    100, abc
    200, bcd
    300, cdf
    400, efg
    500, fgh
    600, ghi
    700, hij
    800, ijk
    900, jkl
    I am trying to achieve through command prompt. the command I am using is
     
    C:UsersAdministrator>BCP TestTask.dbo.BCP In C:UsersAdministratorDesktopExampleBCP.csv 
    -S tcp:<servername style=»color:#111111;font-family:’Segoe UI’, Arial, sans-serif;font-size:14px;line-height:normal;»>.database.windows.net 
    -U 12345admin@<servername>.database.windows.net 
    -P Welc@m#123 -E -h ‘TABLOCK’ -n -k -t ‘,’ -r ‘n'</servername></servername>

Answers

  • Hello,

    Based on the error message, it related to the format file. However, the non-xml format and command is works well on my test environment. Can you try to  create the default format file yourself and then try again. You can create a default format
    file (.fmt) with the following command:

    bcp TestTask.dbo.BCP format nul -n -f C:UsersAdministratorDesktopExamplebcpfmt.fmt -S tcp:servername.database.windows.net -U 12345admin@<servername>.database.windows.net -P Welc@m#123 -k -t ',' -r 'n'

    And then you can modify the format file by remove  the reference to the identity column or you can set the field length to 0. For example:

    3
    1       SQLINT              0       0      ","    1     Id             ""
    2       SQLINT              1       4       ","    2     Value          ""
    3       SQLNCHAR            2       100     "rn"     3     Name           SQL_Latin1_General_CP1_CI_AS

    Reference:Using a Data File with Fewer Fields

    Regards,
    Fanny Liu


    Fanny Liu

    TechNet Community Support

    • Marked as answer by

      Friday, June 20, 2014 2:03 AM

Понравилась статья? Поделить с друзьями:
  • Ошибка sqlserver 773
  • Ошибка srs mercedes 164
  • Ошибка sqlite3 dll
  • Ошибка srs lifan solano
  • Ошибка sql таблица не найдена schemastorage