02102213090 [email protected]
Select Page

Tutorial on how to import a CSV file into SQL Server

In the trenches since 1999

Here is a tutorial on how to import a CSV file into SQL Server:

1. Open SQL Server Management Studio (SSMS) and connect to your SQL Server instance.

2. In the Object Explorer, right-click on the database you want to import the CSV file into, go to Tasks > Import Flat File.

3. In the Import Flat File Wizard, click Next on the welcome screen.

4. On the File to Import screen:
– Select the CSV file you want to import by clicking Browse
– Give the new table a name in the “Destination table name” field
– Click Next

5. On the Preview Data screen, you’ll see a preview of the data from the CSV file. Click Next.

6. On the Modify Columns screen:
– Verify that the column data types were detected correctly
– You can modify the data types for each column if needed
– Click Next when done

7. On the Summary screen, verify the details are correct and click Finish to begin the import process.

8. Wait for the import to complete successfully. You’ll see a green progress bar.

9. Click Close when done. The CSV data is now imported into a new table in your database.

Some key points:

  • Make sure the CSV file is not open in another program when importing
  • You can specify things like row delimiter, column delimiter, text qualifier etc on the Modify Columns screen
  • The first row of the CSV is usually treated as the column headers
  • Large CSV files may take some time to import

This covers the basic process using the Import Flat File Wizard in SSMS to quickly get CSV data into SQL Server tables.

There are also T-SQL commands like BULK INSERT that allow more advanced CSV imports.

we get it done!