0

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 Excel Sheet Image: https://s5.postimg.org/yvmb0ekvr/Untitled.png

Relational Diagram: https://s5.postimg.org/h4aoly5h3/Products.png

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.

Community
  • 1
  • 1
Kashif Ijaz
  • 45
  • 11
  • Please don't just ask us to solve the problem for you. Show us how _you_ tried to solve the problem yourself, then show us _exactly_ what the result was, and tell us why you feel it didn't work. See "[What Have You Tried?](http://whathaveyoutried.com/)" for an excellent article that you _really need to read_. – John Saunders May 24 '15 at 21:46
  • Sorry. but i don't know where to start from. i am begineer. :( – Kashif Ijaz May 24 '15 at 21:58
  • Then maybe this task is beyond you, and you need to get help from someone on your team. [so] isn't a place to come to have your work done for you, or to educate you on how to do things which are outside of your current reach. – John Saunders May 24 '15 at 22:11

1 Answers1

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

Community
  • 1
  • 1
JJS
  • 6,431
  • 1
  • 54
  • 70
  • I can't use ETL tool because excel file will be uploaded to server then i need to read excel file through oledb connection and insert values into tables. – Kashif Ijaz May 24 '15 at 21:53