Answered SQL BULK INSERT skip Lastrow

  • Thursday, June 28, 2012 2:37 PM
     
     

    I am using BULK INSERT in SQL 2005 to upload flat file into table. The file contains header and trailor. I want to skip 1st row and last row.
    I am using below comments (FIRSTROW = 1,LASTROW = -2)

    BULK INSERT IMP_K2OTDaaaa from 'F:\WLL\InputFiles\Calyon\Lora\TEST\JPNC\Backedupfiles\Rec\KONCLPTOJPN_20120628045303.bkp'
     with (FormatFile = 'F:\WLL\InputFiles\Calyon\Lora\TEST\JPNC\Format\IMP_K2OTDaaaa.fmt',FIRSTROW = 1,LASTROW = -2,TabLock)

    However , I am getting the below error , it seems last row = -2 is not accepting.

    Please help .

    Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near '-'.

    Thanks for your help in advance

All Replies