how to create a table in sql server using the xml file

Posted by Sravanthi.seeta under ASP.NET on 1/3/2011 | Points: 10 | Views : 12428 | Status : [Member] | Replies : 4
how to create a table in sql server with a xml file




Responses

Posted by: Raja on: 1/3/2011 [Member] Starter | Points: 25

Up
0
Down
I think directly its not possible, however you can send some kind of flag or table name in xml as parameter to SQL server, read this article how to do that http://www.dotnetfunda.com/articles/article1014-passing-multiple-ids-to-the-database-from-aspnet-application-.aspx and in stored procedure you can write statements to create table.

I know it may not be your exact answer but something that should get you some idea, Thanks

Regards,
Raja, USA

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 1/4/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

If you using stored procedure means must be give the node name of the xml file then only we can read the xml file.But using different nodes of XML file can not use same procedure.
My suggestion is read the xml file using dataset and then to pass the table name and column name into database to create the table.
Refer the following code...


DataSet dsXML = new DataSet();
dsXML.ReadXML("C:\\Test.xml");
string sTableName = dsXML.Tables[0].TableName; // For Table Name


Now you get the XML value into DataSet. what ever you want using DataSet you can do it.

Cheers :)



Thanks,
T.Saravanan

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 1/4/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

Please refer the link: http://www.dotnetfunda.com/codes/code1053-how-to-create-a-table-using-xml-content--sql-server-.aspx

Cheers
www.sqlserverbuddy.blogspot.com


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/4/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Check the below link

http://www.fryan0911.com/2008/10/create-sql-table-script-from-xml-schema.html

Thanks
Karthik
www.f5Debug.net

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response