Hi.. friends,
Its so simple
first of all use this code to write xml file using dot net
using system.Data
using System.Data.SqlClient
Dataset ds=new Dataset()
sqlDataAdapter da=new sqldataadapter("select * from tablename",connectionstring)
da.fill(ds)
ds.writexml("filename")
now Suppose the name of file is abc.xml
and if you want to convert this xml file into table format and insert its values into another table then use the sql server 2005 this procedute........
create proc xyz @xmldoc varchar(max)
as declare @ihandle int
exec Sp_Xml_PrepareDocument @ihandle output, @xmldoc
select * into #tablename1 from openxml(@ihandle,'/newdataset/tablenameofdataset',2) with
( columnname datatypes(size) ,.......)
insert into tablename(columnname.......) select columnname,......... from #tablename1
using this code you can convert xml file into table format after that insert into database
xmdoc is the variable where pass the xml file as a string abd in openxml ()pass 3 argument first is handler sendone isxmlfile firsttablename and third one is 2 and after the with specify all columnsname and datatypes of the table. after that you can do this.
No comments:
Post a Comment