August 21, 2018 at 11:37 pm
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
August 22, 2018 at 5:14 am
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 *******
August 22, 2018 at 6:38 pm
Just delete the blank row after inserting.
August 23, 2018 at 3:48 pm
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
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply