USE NORTHWIND
GO
/*
* Create a stored procedure to delete a product.
*/
CREATE PROCEDURE dbo.ttDeleteProduct
(
@ProductID int
)
AS
BEGIN TRANSACTION
DELETE FROM [Order Details] WHERE ProductID=@ProductID
IF @@ERROR <> 0
ROLLBACK TRANSACTION
ELSE
BEGIN
DELETE FROM Products WHERE ProductID=@ProductID
IF @@ERROR <> 0
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION
END
GO
No comments:
Post a Comment