Load CSV Data into SQL Server Database (Using SSMS)
Import CSV into SQL Server Using SSMS
Follow the steps below to import a CSV (Flat File) into your
SQL Server database using SQL Server Management Studio (SSMS):
Step 1: Open SQL Server Management Studio (SSMS)
- Launch
SSMS.
- Connect
to your SQL Server instance.
Step 2: Select the Target Database
- In Object
Explorer, expand the server.
- Expand
Databases.
- Right-click
the database where you want to import the CSV data.
Step 3: Navigate to the Import Wizard
- Go
to Tasks.
- Click
Import Flat File…
(This option allows importing .csv or .txt files easily.)
- In
the wizard window, click Browse.
- Select
your CSV file
- Enter
the name you want for the SQL table
- Keep
as dbo unless you want a different schema
- Click
Next.
Step 5: Review Column Mapping
- The
wizard will automatically detect columns.
- Validate
the column names and data types.
- Make
corrections if required.
- Click
Next.
Step 6: Load Data
- Review
the summary.
- Click
Finish to start the import.
- Once
the process completes, click Close.
Step 7: Verify Data
- Expand
the Tables folder in your database.
- Open
the newly created table.
- Run
a query such as:
o SELECT
TOP 100 * FROM YourTableName;
- Confirm
that the CSV data is correctly imported.
❗ Facing an Error After Clicking Finish? ❗
✔️ How to Check & Resolve Import Errors
-
In the Results window, click the Error link.
-
Review the detailed error message.
-
Identify:
-
The column name
-
The data type mismatch
-
Invalid values (e.g., text in numeric fields, incorrect date formats)
-
-
Update the column data type.
-
Re-run the import.
Comments
Post a Comment