Results 1 to 2 of 2

Thread: BCP utility in SQL SERVER 7.0

  1. #1
    SRINIVASARAGHAVAN RAGHURAMAN Guest

    BCP utility in SQL SERVER 7.0


    I am trying to do BCP from a comma separator .txt file to upload it into two tables. That is I want the first row (4 columns of header details ) into one table and from the second row (21 columns each of detail rows) to be uploaded into another table. I have written a batch file to upload the header details by giving the first and last column as 1.It is working fine. But when I try to upload the detail rows into another table by giving the first row as 2, the bcp is not able to read from the second row. It skips the second row and reads from the third row. This happens for all separators like pipeline separators also.So to avoid this I have to give blank 21 separators(i.e. , or |) in the second row to avoid the loss of data. Please provide a solution for this, as I cannot insist my customer to provide me a text file with blank comma in the second row.
    Thanks and Regards,
    S.Raghuraman

  2. #2
    Varma Guest

    BCP utility in SQL SERVER 7.0 (reply)

    I don't know about your environment, but it would be easier if you can parse the data file using PERL(or a similar tool) to split it into HEADER and DETAIL data files and then use BCP for the data load.


    ------------
    bc at 3/1/01 1:35:25 PM

    There are probably more intricate answers, but the easiest one is to build a table containing all of the rows, the use a trigger and/or a stored procedure to move the data to the appropriate table


    ------------
    SRINIVASARAGHAVAN RAGHURAMAN at 1/28/01 6:50:36 AM


    I am trying to do BCP from a comma separator .txt file to upload it into two tables. That is I want the first row (4 columns of header details ) into one table and from the second row (21 columns each of detail rows) to be uploaded into another table. I have written a batch file to upload the header details by giving the first and last column as 1.It is working fine. But when I try to upload the detail rows into another table by giving the first row as 2, the bcp is not able to read from the second row. It skips the second row and reads from the third row. This happens for all separators like pipeline separators also.So to avoid this I have to give blank 21 separators(i.e. , or |) in the second row to avoid the loss of data. Please provide a solution for this, as I cannot insist my customer to provide me a text file with blank comma in the second row.
    Thanks and Regards,
    S.Raghuraman

Posting Permissions

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