Code
This is my data. I want to insert my data into 2 table product and parameter.first product data will insert ,and generated id will insert into parameter table.Code
here i am attaching my procedure and current esult and expected result.This is my data. I want to insert my data into 2 table product and parameter.first product data will insert ,and generated id will insert into parameter table.here i am attaching my procedure and current esult and expected result.Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend3days leftRegister
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 19, 2018, 11:55 PM EST
@order nvarchar(max)
)
AS
DECLARE @index int, @OID int
EXEC sp_xml_preparedocument @index OUTPUT, @order
BEGIN TRANSACTION
insert into Tbl_ProductMaster
(ProductName,
ProductDescription,
ClientID ,
IsActive ,
Fromdate,
Todate
)
select PProductName,PDescription,PClientID,'True' as PisActive ,PFromdate,PTodate
FROM OPENXML (@index, '/ArrayOfProduct/Product',2) WITH ( PProductName varchar(50),
PDescription varchar(6),
PClientID varchar(30),
PFromdate datetime,
PTodate datetime )
IF @@ERROR<>0 BEGIN ROLLBACK TRANSACTION RETURN -100 END
SET @OID = IDENT_CURRENT('Tbl_ProductMaster')
INSERT INTO [Tbl_ParameterTransact] ( ProdID, ClientID, ParameterID)
--(2,1,1,@OID)
SELECT @OID AS ProductID,PClientID, PParameterID
FROM OpenXml( @index, '/ArrayOfProduct/Product/GetSetParameter/Parameter',2) WITH
( PClientID int, PParameterID int )
IF @@ERROR<>0 BEGIN ROLLBACK TRANSACTION RETURN -101 END
COMMIT TRANSACTION
EXEC sp_xml_removedocument @index SELECT @OID AS ProductID