Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bulk insert woes

Status
Not open for further replies.

SQLJoe

Technical User
Dec 8, 2010
43
US

I'm having problems with the syntax of the statement below. It keeps giving me a truncation error, even though the datatype in the table (varchar) is plenty long enough. It's supposed to pull data from an excel file on a drive share. Any help is appreciated.

BULK
INSERT dbo.TableName
FROM '\\Servername\FolderName\FileName'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

Error: Bulk load data conversion error (truncation) for row 1, column 1 (ColumnName).
 
pull data from an excel file

Excel does not use comma as a field terminator or new line for a row terminator. In fact, you cannot use bulk insert to load data from an excel file.

For excel files, I would encourage you to do some research on [google]SQL Server OpenRowset Excel File[/google] function.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
...Unless you meant a CSV file saved from Excel, in which case - have you got column headings in the first line? If so, add the option
Code:
...
FIRSTROW = 2,
...
HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top