USE [Northwind]
GO
IF OBJECT_ID('Pr_DeleteCustomers') IS NOT NULL
BEGIN
DROP PROCEDURE Pr_DeleteCustomers
PRINT '<< Pr_DeleteCustomers procedure dropped >>'
END
GO
CREATE PROCEDURE Pr_DeleteCustomers
@Customers XML
AS
BEGIN
/*
Purpose : Delete the n number of customers using the XML in the Customer Table.
Here i have created the one more column as Active to update the status.
Input : Get the Customers ID in the XML format from the front-end application.
Output : Return 1 as success, and -1 as failure
Created On : July 28, 2009
Created By : Erode Senthilkumar
**************************************************************************
---------------------------------- Modification History ---------------------------------------
**************************************************************************
S.No Name Changes
**************************************************************************
1. Erode Senthilkumar Initial Version
**************************************************************************
*/
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE @hDoc INT
EXEC sp_xml_preparedocument @hDoc OUTPUT,@Customers
UPDATE Customers SET cStatus='D' WHERE CustomerID IN
(SELECT ID FROM OPENXML(@hDoc,'/Customers/Customer',2) WITH (ID VARCHAR(10)))
IF @@ERROR <> 0
BEGIN
RETURN -1
END
ELSE
BEGIN
RETURN 1
END
END
GO
IF OBJECT_ID('Pr_DeleteCustomers') IS NOT NULL
BEGIN
PRINT '<< Pr_DeleteCustomers procedure created >>'
END
GO |