Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML Basic - SQL Server 2000
Message
 
 
À
31/08/2005 14:14:26
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01045608
Message ID:
01045630
Vues:
23
DECLARE @idoc int

EXEC sp_xml_preparedocument @idoc OUTPUT, @xml

INSERT INTO Employee 
SELECT * FROM OPENXML( @idoc, '/Root/Record', 2 ) WITH (
	Name varchar(50),
	Age int,
	City varchar(50),
	State varchar(50)

EXEC sp_xml_removedocument @idoc
>I have received a XML file that looks like
>
>
><Root>
>   <Record>
>      <Name>John</Name>
>      <Age>42</Age>
>   </Record>
>   <Record>
>      <Name>Jeff</Name>
>      <Age>18</Age>
>      <State>VA</State>
>   </Record>
>   <Record>
>      <Name>Judy</Name>
>      <City>Raleigh</City>
>      <State>NC</State>
>   </Record>
></Root>
>
>
>and need to insert the data in Employee table that has the following structure:
>
>
>	<Emp_Name>  <varchar> (50) NOT NULL
>	<Emp_Age>   <int>          NULL
>	<Emp_City>  <varchar> (50) NULL
>	<Emp_State> <varchar> (50) NULL
>
>
>Is there an easy way to do this?
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform