I want to store data in two tables using stored procedure but I've faced problem , so I've tried to make something like this:
CREATE proc [dbo].[store]
CREATE proc [dbo].[store]
(@TrnId int
,@prdctName nvarchar(50)
,@ordrdQnty int
,@ordrPrice money
,@OrdrId int
,@TrnDate datetime
,@TrnTotal money)
as
begin transaction trs
INSERT INTO [dbo].[OrderProduct]
(--[TrnId],
[prdctName]
,[ordrdQnty]
,[ordrPrice])
VALUES
(--( SELECT @@IDENTITY from [Transaction] ),
@prdctName
,@ordrdQnty
,@ordrPrice )
if @@ERROR<>0 goto Err_
INSERT INTO [dbo].[Transaction]
(
[OrdrId]
,[TrnDate]
,[TrnTotal])
VALUES
( @OrdrId ,CURRENT_TIMESTAMP ,@TrnTotal)
if @@ERROR<>0 goto Err_
commit tran
return 0
Err_:
rollback
return 1
============
but it doesn't work,
Could you help me please ....