SQL SERVER – Importing CSV File Into Database – SQL in Sixty Seconds #018 – Video

Importing data into database is one of the most important tasks. I often receive questions regarding what is the quickest way to insert CSV data or how to import CSV Data into SQL Server Table. Honestly the process is very simple and the script is even simpler. In today’s SQL in Sixty Seconds Video we will learn how quickly we can insert CSV data into SQL Server.

The steps to import CSV are very simple.

  • Create Table
  • Use Bulk Insert to import the data
  • Verify the data
Done! Absolutely it is that simple.

More on Importing CSV Data:

I encourage you to submit your ideas for SQL in Sixty Seconds. We will try to accommodate as many as we can.

If we like your idea we promise to share with you educational material.

Reference: Pinal Dave (http://blog.sqlauthority.com)

About these ads

13 thoughts on “SQL SERVER – Importing CSV File Into Database – SQL in Sixty Seconds #018 – Video

  1. I have arround 16 crores of records in 16 csv files each having 1 crores of records. It is all about TRAI registred Mobile number and some other information.
    I am using Mysql and Sql server also.

    I am using bulk insert but it is too slow.

    How efficiently I can upload and also Update new date for each week.(update twice in a week)

    Please advice.

  2. Pingback: SQL SERVER – Powershell – Importing CSV File Into Database – Video « SQL Server Journey with SQL Authority

  3. What would be really useful is a script that created the table and imported the data to that table. This seems quite tedious. For example, why would I go through all of the trouble creating the table, then creating a script identifying the table headers then importing all of the data.

    What I would like to see here is a REAL USEFUL import CSV file, taking the first line as the header (Don’t forget to add the record Numbers Incremental) and then adding the data to those headers. Can this be done?

  4. I am getting below error.

    The OLE DB provider “BULK” for linked server “(null)” reported an error. The provider did not give any information about the error.

  5. $value) $data[$key] = addslashes($data[$key]);
    $con = mysql_connect($server,$DBusername,$DBpassword);
    mysql_select_db($database, $con);
    //mysql_connect($server, $DBusername, $DBpassword) or die (“$DatabaseError 54″);
    echo $query = mysql_query(“INSERT INTO $tablename (

    `name`,
    `text`
    )
    VALUES(‘$data[0]‘, ‘$data[1]‘)”);
    $result = mysql_query($query);

    }

    }

    ?>

  6. I am using:
    BULK INSERT mdb_cleanse.dbo.[@repository employee list]
    FROM ‘C:\Users\fa01jjm\Documents\SQL Server Management Studio\Projects\Run Queries\Employee_List.csv’
    WITH
    (
    FIELDTERMINATOR = ‘,’,
    ROWTERMINATOR = ‘\n’
    )

    I get an error saying the OS cannot find the path specified

  7. Pingback: SQL SERVER – Weekly Series – Memory Lane – #034 | Journey to SQL Authority with Pinal Dave

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 )

Google+ photo

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

Connecting to %s