eighthman11
2012-04-16 15:07:56 UTC
Good Morning. I'm doing a bulk insert in a stored procedure. The
source file is a tab delimited file which was created from an excel
spreadsheet. I'm using SQL Server 2008. Below is the code I am using
for the bulk insert.
BULK INSERT #MyBulkData
FROM '\\Nccs-db03\UploadFolder\textfile.txt'
WITH(FIELDTERMINATOR = '\t')
OK here's the problem. The excel spreadsheet which is the source file
that I save as a tab delimited text file has a column for "day
worked". The "day worked" is not on every row in the spreadsheet.
The day worked only appears when the "day worked" changes. So after I
do the Bulk import I loop through the records and fill in the blank
"day worked" field based on the previous "day worked" record.
The problem is when doing the bulk insert I have to have the records
insert in the exact same order as the source file or I can't loop
through the records and update the proper "day worked". The bulk
insert; inserts the record in the exact same order as the text file
about 90 percent of the time, but occasionally it just goes crazy.
I hope I am making sense with this and any help would be appreciated.
Thanks
Ray
source file is a tab delimited file which was created from an excel
spreadsheet. I'm using SQL Server 2008. Below is the code I am using
for the bulk insert.
BULK INSERT #MyBulkData
FROM '\\Nccs-db03\UploadFolder\textfile.txt'
WITH(FIELDTERMINATOR = '\t')
OK here's the problem. The excel spreadsheet which is the source file
that I save as a tab delimited text file has a column for "day
worked". The "day worked" is not on every row in the spreadsheet.
The day worked only appears when the "day worked" changes. So after I
do the Bulk import I loop through the records and fill in the blank
"day worked" field based on the previous "day worked" record.
The problem is when doing the bulk insert I have to have the records
insert in the exact same order as the source file or I can't loop
through the records and update the proper "day worked". The bulk
insert; inserts the record in the exact same order as the text file
about 90 percent of the time, but occasionally it just goes crazy.
I hope I am making sense with this and any help would be appreciated.
Thanks
Ray