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

Merryj
Posted by Merryj under Sql Server category on | Points: 40 | Views : 1833
Create procedure [dbo].[SavePersonDetails]
(
@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>'
insert into tblPerson(FirstName,LastName,Person_Address)
values(@FirstName,@LastName,@xmlAddress)
end

Comments or Responses

Login to post response