Import .CSV to SQL Table

BULK INSERT New_Table
FROM 'c:\csvfile.txt'  --or a .csv file
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO

8-O
Yes, so gracefully simple…

Just create the table beforehand :-)

~ by Francois Wiid on February 19, 2008.

4 Responses to “Import .CSV to SQL Table”

  1. OMW i am so going to kill you for this. Been searching for a way to do something like this and just kept on hitting dead ends.

    Gratis

  2. Hello Readers,

    Please go to following link :

    http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/

    It has explained the same concept in detail.

    Regards,
    Pinal Dave ( http://www.SQLAuthority.com )

  3. [...] Import .CSV to SQL Table [...]

  4. I’m using the same insert code but FIELDTERMINATOR = ‘”,”‘ however when their is a Null in a column it throws an error. Is there anyway round this?
    Thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.