Reading Text in sql

  • Hi,

    I have text file having 2000 rows. These rows may start with 'Msg' or 'Bulk' values. This is the error output file from sql.

    I want to read this and insert rows starting with 'Msg' into a table in sql.

    I am trying this in sql only. Bulk insert will not work for this scenario, since we can't check the row starting value.

    Please suggest ur ideas if anyone faced this.

    Thanks,

    Peer Md.

  • One method is to use the OPENROWSET command to read the data and then filter the records out of this query. Another alternative that you don't seem to want is to use BULK LOAD to load all of the records into a table and then process the data out of the "stage" table to fetch the desired records. You might also want to consider creating an SSIS package to import your data.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply