Microsoft
Software
Hardware
Network
Question : Importing CSV file into database table using OPENROWSET
Hello,
I am trying to import a CSV file into a SQL Server 2005 database table using the OPENROWSET command. I have the following script working which lists the output of the CSV correctly:
SELECT *
FROM OPENROWSET
('MSDASQL','Driver={Micros
oft Text Driver (*.txt; *.csv)};DefaultDir=C:\File
s\CSV','SE
LECT * FROM example3.csv')
How do I adjust the above script to copy the contents of the CSV file to a database table in which all the fields in the CSV file map directly to the fields in the database table?
The exampe CSV file and table is a very simple example. I actually intend to apply this to very large CSV files so performance is very important. I understand there is a way to bulk import using OPENROWSET but not sure how.
Please do not suggest solutions using BULK INSERT as my post only relates to OPENROWSET.
Answer : Importing CSV file into database table using OPENROWSET
you mean:
INSERT INTO yourtable (col1, col2, col3 ... )
SELECT field1, field2, field3 ...
FROM OPENROWSET
('MSDASQL','Driver={Micros
oft Text Driver (*.txt; *.csv)};DefaultDir=C:\File
s\CSV','SE
LECT * FROM example3.csv')
Random Solutions
Microsoft SSIS Service failed to start. Error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
MS Project 2007, How to add a Column 'Percent'
vb.net selected item from listview
How to build a control by its name as a string
New RAM Causing laptop to shut down
How to Send Alert Info from Dell Open Manager Via Email
Regional settings GREEK , decimal separator "," sql server 2000, But does not update a textbox tha binds to a float field,C# framework 2.0
Find a Text in a cell and copy it to another cell.
Access 2003: shell command - quest 2
Drawing and Scolling in Windows C# - ClientRectangle? Paint?