If EXISTS (SELECT Name from sysobjects where name = n'getpeople 'and type =' p ') Drop Procedure getPeopleGo
CREATE PROCEDURE getPeopleASdeclare @au_lname varchar (40), @ au_fname varchar (40), @ returnXML varchar (4000) DECLARE Employee_Cursor CURSOR FORSELECT LastName, FirstName FROM Northwind.dbo.EmployeesOPEN Employee_Cursorset @returnXML = '' FETCH NEXT FROM Employee_Cursorinto @ au_lname, @ au_fnameWHILE @@ FETCH_STATUS = 0BEGIN set @returnXML = rtrim (@returnXML) ' ' @au_lname ' lname> ' @au_fname ' fname> < / people> 'FETCH NEXT FROM Employee_Cursor into @ au_lname, @ au_fnameENDset @returnXML = rtrim (@returnXML) ' peoples> 'CLOSE Employee_CursorDEALLOCATE Employee_Cursorselect @returnXMLGO