Two comments on the previous code: 1. If there is any chance the Xml document could be larger than 8000 characters consider using text or if you are using SQL Server 2005 varchar(MAX).
2. There is no need to use a CURSOR for something as simple as this. You can do something like this:
Create Procedure usp_DeleteItems @XmlDoc text AS
Declare @idoc int
SET NOCOUNT ON EXEC sp_xml_preparedocument @iDoc OUTPUT, @XmlDoc
Delete i From Items i Inner Join ( SELECT ItemID, EmpID From OPENXML(@iDoc, '/items/item', 1) WITH ( ItemID int '@itemid', EmpID int '@empid')) x On i.ItemID = x.ItemID And i.EmpID = x.EmpID -- Assuming that both ItemID and EmpID are required
EXEC sp_xml_removedocument @iDoc
|