How to update Address as an xml datatype value in a table using a procedure?

Merryj
Posted by Merryj under Sql Server category on | Points: 40 | Views : 1651
Create procedure [dbo].[UpdatePersonDetails]
@id int,
@FirstName varchar(50),
@LastName varchar(50),
@HouseName varchar(30),
@HouseNumber varchar(30),
@City varchar(30),
@PO varchar(30),
@Pin varchar(10),
@State varchar(30)
as
begin
declare @xmlAddress xml
set @xmlAddress='<person>
<HouseName>'+@HouseName+'</HouseName>
<HouseNumber>'+@HouseNumber+'</HouseNumber>
<City>'+@City+'</City>
<PO>'+@PO+'</PO>
<Pin>'+@Pin+'</Pin>
<State>'+@State+'</State>
</person>'
update tblPerson
set FirstName=@FirstName,LastName=@LastName,Person_Address=@xmlAddress
where Person_Id=@id
end

Comments or Responses

Login to post response