Hi all,
I have a question regards to store procedure in SQL to delete records. Here is my code:
CREATE PROCEDURE dbo.deleteCustomer_Records
@CustomerID INT
AS
BEGIN
Delete from OrderDetail AS A INNER JOIN OrderID B ON A.OrderID = B.OrderID
WHERE
B.CustomerID= @CustomerID
END
GO
I have 3 tables, table Customer with columns: CustomerID, CustomerName... table Order with columns: OrderID, CustomerID, OrderName.. and my OrderDetail with columns: OrderDetailID,OrderID, OrderDetailName... I want to delete all records on OrderDetail tables belong to that customer when I have the CustomerID. I tried to build a delete function in store produre with the INNER JOIN feature.
BUT IT DOES NOT WORK! ANYONE HAVE ANY IDEA FOR THIS STORE PROCEDURE???
Thank you,
lehuong
I have a question regards to store procedure in SQL to delete records. Here is my code:
CREATE PROCEDURE dbo.deleteCustomer_Records
@CustomerID INT
AS
BEGIN
Delete from OrderDetail AS A INNER JOIN OrderID B ON A.OrderID = B.OrderID
WHERE
B.CustomerID= @CustomerID
END
GO
I have 3 tables, table Customer with columns: CustomerID, CustomerName... table Order with columns: OrderID, CustomerID, OrderName.. and my OrderDetail with columns: OrderDetailID,OrderID, OrderDetailName... I want to delete all records on OrderDetail tables belong to that customer when I have the CustomerID. I tried to build a delete function in store produre with the INNER JOIN feature.
BUT IT DOES NOT WORK! ANYONE HAVE ANY IDEA FOR THIS STORE PROCEDURE???
Thank you,
lehuong