CREATE PROCEDURE spAddOrderTransactions
@CustomerID nchar (5),
@ShipperID int,
@ProductID int,
@UnitPrice money,
@Quantity smallint,
@Discount real,
@OrderID int output
   AS
Begin Transaction
-- declare @OrderID int
Insert into Orders (CustomerID, ShipVia)
values (@CustomerID, @ShipperID)
select @OrderID = @@identity
if @@Error <> 0 goto ErrorHandler
Insert into [Order Details]
(OrderID, ProductID, UnitPrice, Quantity, Discount)
values
(@OrderID, @ProductID, @UnitPrice, @Quantity, @Discount)

if @@Error <> 0 goto ErrorHandler
commit transaction
return
ErrorHandler:
rollback transaction
return
GO
