sql server - How to perform Insert when more tables are related -
After
I have created table 3 in the database as tbProducts, tbLineOfAuthority, tbProductLineOfAuthority
tbProducts after feilds
tbLineOfAuthority occurs after feilds
Now include tbLineOfAuthority
- 1 - Electronic insurance
- 2 - Number
- 3 - Creativity
- 4 - Debit
In the front I have the form with the following types
If user
Now my question is based on the requirement above to insert operation in MS SQL Server and if more than two tables related to the foreign key Are there.
I have written the stored procedure as
Insert tbProduct (product name, ProductDescription) value (@ProductName, @ProductDescription) I am confused about how I will write a stored procedure which automatically updates tbProductLineOfAuthority (productId and LineOfAuthorityId)
What will happen besides the selection of several lines of authorization from the user's inquiry In the form of boxes, I mean that the user's casuality, credit and Will select Ebit.
Please help me!
To cap the cap, you must type tbProducts
and tbLineOfAuthority < For the table / table, some 3 parameters will be given below for the table, once you have entered the record, use SCOPE_IDENTITY ()
to identify the newly created code [Note that both tables PK columns are identity
column].
Create process sp_insert_ops (@ product name, @ productive description, @tbinlineoff authority) starting @tbProduct_ID INT; Enter the TbProduct (Product Name, Product-Category) Price (@ Product Name, Product Details); SELECT @tbProduct_ID = SCOPE_IDENTITY (); Include TbProductLineOfAuthority (Product ID, LineAff Authority) values (@tbProduct_ID, NULL); End
Comments
Post a Comment