Bullk insert in sql server..

  • Hi all ,
    I have text file with second row is blank,data start with 3rd row .due to one server to  server data moving.
    in bulk insert that not up due to blank row and there is some space between two fields  also .
    how to up file in sql server without any changes .

    emp_id|emp_name|join_date|dept_name|salary

    1000|roky|12-Jul-17|IT|20000
    1001|ram| 12-Jul-16| IT|30000
    1002|sam| 01-May-15|IT|15000
    1003|tom|21-Dec-10|IT| 25000

    .
    .
    .
    .

    87506 rows selected.

    regards
    santosh

    Best Regards
    Santosh Ghogare

  • im not 100 sure exactly what you want but if the second line is always blank then start at the 3rd 

     BULK  INSERT Table_name  FROM  path_filename  WITH  (FIRSTROW = 3,FIELDTERMINATOR = '','',ROWTERMINATOR = ''\n'')

    ***The first step is always the hardest *******

  • Just delete the blank row after inserting.

  • Unless they've changed it recently, BULK INSERT and BCP are delimiter sensitive when it comes to counting rows rather than what humans perceive to be a line in a file.  If you don't have the same delimiters on row 1 and 2 as there are in the "body" of the rest of the file, you'll either get an error or you'll be missing some data in all but the perfect accident.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

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