To load a CSV file into SQL Server using SSIS, follow these steps:
Create a table on SQL server:
Create a new Integration Services Project:
Launch Microsoft Visual Studio and create a new Integration Services Project. Rename the default package to something meaningful, such as “Load CSV File into SQL Server”.
Setup Connection Managers:
At the bottom of the screen, under Connection Managers, right-click and select “New Flat File Connection”. Configure the Flat file connection manager by entering a suitable Connection manager name and specifying the file path for the CSV file. Click OK.
Create a SQL Connection:
For the table’s connection manager, right-click again in the Connection Managers window and click on “New OLE DB Connection”. Click on New and specify the Server name and database name that contains the table where you want to load the CSV data.
Create a Data Flow Task:
On the left side of the screen, in the SSIS Toolbar, drag the “Data Flow” to the “Control Flow” window and rename the task to “Load CSV File”.
Configure the Flat File Source:
Drag the “Flat File Source” from the SSIS Toolbox into the “Data Flow” window and rename it as “CSV File”. Double click on this source and select the CSV file connection manager you created earlier. Click on Columns on the left side of the screen to review the columns in the file. Click OK.
Configure the OLE DB Destination:
Then drag the “OLE DB Destination” from the SSIS Toolbox to the “Data Flow” window and rename it as “SQL Table”. Drag the blue arrow from the source to the destination. Double click on the destination and configure it to point to the SQL Server table where you want to load the data. Click on Mappings on the left side of the screen and ensure all fields are mapped correctly from source to destination.
Run the Package:
Finally, run the package by clicking on Start. When the package finishes executing, you can check the table to view the data from the CSV file.
This process will create a new Integration Services project, configure the necessary connection managers, and create a data flow task to load the data from the CSV file into the SQL Server table. It’s important to note that the structure of the CSV file and the SQL Server table should match for this process to work correctly.
Data Source: Generate dummy data by AI
Trademark Disclaimer:
All trademarks, logos, and brand names are the property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names trademarks, and brands do not imply endorsement.