"In order to add the correct value in the ORDERDETAIL's ORDERID field, you must update the ORDER table first to get the ORDERID value assigned by the system, and then fill the ORDERDETAIL table with this ORDERID. Finally update the OderDetail table. But, to ensure data Consistency, ORDER and ORDERDETAIL must be performed at the same time under transaction protection, to ensure that the scale is successful. Obviously they are conflict. "I think the contradictions here can be solved, is being processed. In an ERP project, the insertion of several tables is threated, and the specific processing is: 1. Construction of a big thing in the program, including the insertion of the primary table and slave table. 2, the master-slave table is inserted with the stored procedure. After the main table stored procedure is successful, return the correct ID value, insertion of the slave table; give one -1 if not successful primary table, indicate unsuccessful, then the program control Do not interpolate the table .3, only the master is inserted from the table, and the big matter will be submitted. Of course, pay attention to some details: 1. Consider the user's scalability: The reason is: The customer has only one part has an order operation. If there are two departments now, the order number is written, you will not be able to operate.
In the SQL Server, copy a table from the database to another, by generating a script, then run the script by querying the analyzer, but the default and primary keys and instructions are lost, just because the generated script does not include These contents. The "Generation Create Script" in the server resource manager comes with .NET can generate scripts of the relevant content.