SQL: How do I bulk insert this data?
Posted on 2011-03-09
I'm new to MS-SQL. I'm familiar with bulk-inserting from a CSV, however I have a set of data in text files that is not delimited the way a CSV would be and I need to get this into a SQL database.
The data is in a text file, contained in 4-line sets (so each row is four lines), for example:
I need to import this data into columns as follows:
Column Name - Data
Cell_No - 7
Tile_No - 1
X_Coord - 6770 [the length of this number could be 1-10 digits]
Y_Coord - 966 [the length of this number could be 1-10 digits]
Pair - 2
Sequence - [all of line 2]
The rest of the information is unimportant.
Essentially, I need to extract bits of data from line 1 and place into multuple columns, place all of line 2 in its own column and ignore lines 3 and 4. I'm not sure how to write the bulk insert sql to do this. Can anyone provide an example from a similar import that they have done to get me started?