Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import first 1000 records into sql server from a csv file

I need to import a csv file into sql server table, but i only want to import the first 1000 records of the csv file.

This is my sql code,

USE MyDB
BULK INSERT MyTable
FROM 'C:\Users\jasons\Desktop\Documents\MyFile.csv'
WITH(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

What do i need to add or how can i change my code to only import the first 1000 records.

like image 666
Jason Samuels Avatar asked Mar 18 '23 11:03

Jason Samuels


1 Answers

USE MyDB
BULK INSERT MyTable
FROM 'C:\Users\jasons\Desktop\Documents\MyFile.csv'
WITH(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
LASTROW = 1001
)
like image 183
MikkaRin Avatar answered Mar 21 '23 06:03

MikkaRin