I have some rules set up in Dev and working fine. Now, I want to copy the same rules to QA. There are 4 tables involved and the table structure is the same in dev and QA. I just want to move data from dev to QA.
If anything breaks, I would like revert completely.
- Products table
- Products Group Table (Product_Id FK from products table)
- Products SubGroup Table (Group_Id FK from Products Group table)
- Properties Table (Subgroup_Id FK from Products SubGroup table)
What is the efficient way of writing a stored procedure to do this?
I tried below and because of cross join, it is dupicating records.
DECLARE @TempProducts TABLE (ProductId INT); INSERT INTO Products (Product_NAME, Product_DESCRIPTION, UPDATED_DATE, CREATED_DATE, CREATED_BY, UPDATED_BY) OUTPUT INSERTED.product_ID INTO @TempProducts SELECT Product_NAME, Product_DESCRIPTION, getDate(), getDate(), UPDATED_BY, CREATED_BY, FROM [dbo].[Products] P JOIN Product_GROUP PG ON P.Product_ID = PG.Product_Id CROSS JOIN @TempProducts WHERE PG.Product_ID = 2