home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,585 of 19,505   
   George Neuner to eighthman11@yahoo.com   
   Re: Bulk Insert Erratic insert order. An   
   16 Apr 12 23:56:15   
   
   fc2a5c0d   
   From: gneuner2@comcast.net   
      
   On Mon, 16 Apr 2012 08:10:45 -0700 (PDT), eighthman11   
    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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca