Click to See Complete Forum and Search --> : Copying data( in text file) onto a table


sudpat
March 6th, 2006, 04:32 PM
Hi,

I have to transfer a text file which have rows in a pattern as shown below:-

00000000234| 0003434343|Michael|Derosal|001020| | | |

"|" is the delimetor the last 3 delimiter's basically specify that last 3 columns are blank.

Which transfer protocol I can use( BCP etc) and how to use it since I have a delimiter "|" seperating each column.

Any help would be greatly appreciated.

Krzemo
March 7th, 2006, 03:03 AM
Since it seams U have SQL Server:

BULK INSERT [ [ 'database_name'.] [ 'owner' ].] { 'table_name' FROM 'data_file'}[ WITH
(
[ BATCHSIZE [ = batch_size ] ]
[ [ , ] CHECK_CONSTRAINTS ]
[ [ , ] CODEPAGE [ = 'ACP' | 'OEM' | 'RAW' | 'code_page' ] ]
[ [ , ] DATAFILETYPE [ =
{ 'char' | 'native'| 'widechar' | 'widenative' } ] ]
[ [ , ] FIELDTERMINATOR [ = 'field_terminator' ] ]
[ [ , ] FIRSTROW[ = first_row ] ]
[ [ , ] FIRE_TRIGGERS ]
[ [ , ] FORMATFILE = 'format_file_path' ]
[ [ , ] KEEPIDENTITY ]
[ [ , ] KEEPNULLS ]
[ [ , ] KILOBYTES_PER_BATCH [ = kilobytes_per_batch ] ]
[ [ , ] LASTROW [ = last_row ] ]
[ [ , ] MAXERRORS [ = max_errors ] ]
[ [ , ] ORDER ( { column [ ASC | DESC ] } [ ,...n ] ) ]
[ [ , ] ROWS_PER_BATCH [ = rows_per_batch ] ] [ [ , ] ROWTERMINATOR [ = 'row_terminator' ] ]
[ [ , ] TABLOCK ]
)
]

See SQL Server Books Online...