0

I would like to write a program like sales in which there's two table to insert i.e: SaleHeader Table and SaleDetails Table. These two tables have (one to many) relationship. When I insert to SaleDetails Table I need to get SaleHeaderID to insert at SaleDetails.

Now I am using a stored procedure to insert SaleHeader information and to get back SaleHeaderID and I use query statements to insert SaleDetail information.

Any one can advise me for more effective way to insert to those two tables (having one to many relationship) ? Help me! Thanks in advance all.

1
  • this really has nothing to do w/vb.... Commented Nov 6, 2009 at 6:38

1 Answer 1

1

One approach is to use a Guid for the SaleHeaderID. Then you can generate the new id in your stored procedure (using NEWID()) before inserting the header record, and then you will also know the id so you can use it for the details.

Sign up to request clarification or add additional context in comments.

1 Comment

How about using SELECT IDENTITY() , because my SaleHeaderID is bigint Type? I would like to know is the other approach besides using stored procedure for SaleHeader Table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.