February 4, 2015 at 2:00 am
Hi Guys,
I urgently need some help using BCP.
When I try to copy data from an Excel spreadsheet file it gives me the following error: SQLState = S1000, Native Error = 0 and then it says Sql Server Native Client 10.0 Unable to open BCP host data file
My command is bcp DBName.dbo.TableName in C:\testing.xls -c -T -t.
Why is this not working?
Any help will be greatly appreciated.
Thanks Guys
February 4, 2015 at 5:24 am
I have now changed the file name to Capitals, is the bcp case sensitive?
Now it says starting copy, then gives me SQLState = 220011, Native Error = 0.
String data right truncation
February 4, 2015 at 5:33 am
Sounds like the data in your spreadsheet is too wide to insert into at least one of the columns in your table.
John
February 4, 2015 at 5:45 am
What you says makes sense since this is what I have found when searching the error, but when I use the Import wizard to do it, it creates a new table for the data. Then I just insert all off that data into my table and I dont get any errors? One thing I have noticed is that the new table that gets created sometimes get an extra column that does not appear in the excel spreadsheet. How is this possible?
February 4, 2015 at 5:54 am
If I remember correctly, when data is imported from Excel, it only looks at the first half dozen or so rows in order to determine the width of the columns. You probably ought to create the table explicitly based on your familiarity with the data.
John
February 4, 2015 at 5:58 am
I created the table exactly like the spreadsheet. The format of the spreadsheet will never change and I made the data types more than big enough to handle the data coming in
February 4, 2015 at 7:37 am
My final command is now:
bcp DBName.dbo.TableName IN FilePath -T -t -f FormatFilePath
This gives no error, it only says
Starting Copy....
0 Rows Copied
Network Packet Size (bytes): 4096
Clock Time (ms.) Total : 1
February 4, 2015 at 8:30 pm
BCP cannot import .XLS (Excel spreadsheet) files... period. If you're trying to import a spreadsheet to SQL Server via T-SQL, you need to use the "ACE" drivers and either OPENQUERY and OPENROWSET.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 4, 2015 at 11:44 pm
I wanted to use the openrowset statement in sql but it complains about my drivers.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply