Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #983
| From | George Neuner <gneuner2@comcast.net> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: Bulk Insert Erratic insert order. Any Help Greatly Appreciated. |
| Date | 2012-04-16 23:56 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <n0ppo7lo4g4altljolpdme9e868fjt21oa@4ax.com> (permalink) |
| References | <fd029dc0-391c-41f5-9c00-4f3e98fcb713@b2g2000yqb.googlegroups.com> |
On Mon, 16 Apr 2012 08:10:45 -0700 (PDT), eighthman11 <eighthman11@yahoo.com> wrote: >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. > >Ray Perhaps a dumb question ... but why not correct the data before importing it? I would just write a little program to insert the missing fields while copying the original data. As an aside, YMMV but personally I avoid the use of tabs as delimiters. Tabs are nice for visually examining a file, but a printable character is better for programmatic manipulation. If you need to, you always can pipe the file through a filter to change the field delimiters to tabs. George
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Find similar
Bulk Insert Erratic insert order. Any Help Greatly Appreciated. eighthman11 <eighthman11@yahoo.com> - 2012-04-16 08:10 -0700
Re: Bulk Insert Erratic insert order. Any Help Greatly Appreciated. Tony Toews <ttoews@telusplanet.net> - 2012-04-16 11:17 -0600
Re: Bulk Insert Erratic insert order. Any Help Greatly Appreciated. eighthman11 <eighthman11@yahoo.com> - 2012-04-16 10:49 -0700
Re: Bulk Insert Erratic insert order. Any Help Greatly Appreciated. "Fred." <ghrno-google@yahoo.com> - 2012-04-16 10:50 -0700
Re: Bulk Insert Erratic insert order. Any Help Greatly Appreciated. George Neuner <gneuner2@comcast.net> - 2012-04-16 23:56 -0400
csiph-web