I want to insert data from excel sheet to multiple tables i used sqlbulk to insert data in 1 table. tables are linked with foriegn keys. first data will be inserted in parent table after that data will go in child table.
My Question is how can i insert excel data into different tables from parent to child. I mean First data will go in Category Table then Sub-Category Table, then Brand Table, then Model table and at last Products_Info table.
答案 0 :(得分:0)
You can bulk insert your initial data into a staging table. Then use a series of statements to create your data in each lookup table.
How to use BULK INSERT when rows depend on foreign keys values?
Another tool in the MSSQL platform is SQL Server Integration Services, a more robust ETL tool. You're describing a scenario where the Lookup Task really shines. SSIS Lookup Task