5

I am trying to import a CSV file in SQL Server 2008. BULK INSERT is a way to go but it is applicable for CSV from SQL Server 2014 onwards.

What would be an alternative way to achieve this goal?

Any thoughts/ideas much appreciated.

1
  • 2
    Actually FORMAT='CSV' is 2017+ (14 is the major version number). Commented Nov 5, 2018 at 16:00

2 Answers 2

10

SQL Server has always supported bulk inserting from CSV files, you just have to specify field/row terminators.

file.csv contains:

foo,bar,1
blat,splunge,2

Then we do this:

CREATE TABLE #foo(a varchar(32), b varchar(32), c int);

BULK INSERT #foo FROM 'c:\temp\file.csv'
WITH (ROWTERMINATOR = '\n', FIELDTERMINATOR = ',');

SELECT * FROM #foo;

Results:

a        b        c
-------- -------- ----
foo      bar      1
blat     splunge  2
2

Following link

https://support.discountasp.net/kb/a1179/how-to-import-a-csv-file-into-a-database-using-sql-server-management-studio.aspx

enter image description here

If you problem then next link follow I hope solve your problem

https://host4asp.net/import-csv-file-using-sql-server-management-studio/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.