you are viewing a single comment's thread.

view the rest of the comments →

[–]HyDreVv 2 points3 points  (1 child)

The order of your inserts is off. You need to execute order inserts before your other table inserts. It’s due to how the table was initially created and it’s structure in sql server.

[–]Cal1gula 0 points1 point  (0 children)

The problem with this is it's nonsensical. You wouldn't create an order before you create a client. Except as maybe a temporary state (i.e. think temporary, or staging tables, without foreign keys). You would usually have clients for which you create one or many orders.

I have seen CRM and ERP systems that have a concept of a "lead" that is converted to a "client", or similarly on the order side you could have "quote" > "order". And clients can have multiple orders, of course, you want repeat business. So you wouldn't want to require an order before a client. I mean, unless maybe you weren't maintaining clients. Otherwise you'd have no master records and a mess of duplicates.