CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    9

    Copying data( in text file) onto a table

    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.

  2. #2
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: Copying data( in text file) onto a table

    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured