"Priya" <pr****************@gmail.comwrote in message
news:11**********************@e1g2000hsg.googlegro ups.com...
Hey all,
Is there a way to create a table in the SQL database by using an XML
file as an input? I want to have an XML file which holds all the
details of the table like the tablename, columns, datatypes, table
constraints etc.. This XML file should be read and parsed to create a
table in SQL according to the specification provided in the XML file.
I am not sure how to proceed with this. Any help would be appreciated.
Using the following XML as a basis for discussion:
<?xml version="1.0" encoding="utf-8" ?>
<Customers>
<Customer>
<Name>Me</Name>
<Address>There</Address>
<Age>21</Age>
</Customer>
<Customer>
<Name>Me with A Very Big Name Eh (cause I'm Canadian)</Name>
<Address>There is another long address since Canada is a big
country</Address>
<Age>N/A</Age>
<Degree>BSC</Degree>
</Customer>
</Customers>
Now with the above XML it can be inferred that the table name would be
Customers and each Customer(s) row would have Name, Address and Age fields.
You can find the node names using the XML namespace in Dot.Net.
The interesting part comes now.
Each "row" would have to be read and for each "column" both the type and max
length of the data would need to be determined. Notice that in the first
"row" Age is numeric but in the last it is a string. Those are the types of
things you will have to deal with.
Another case is in the last "row" there is a Degree field that does not
exist in other places so you would need to create a column for that with a
default value or null for all rows with out this value.
Good luck
Lloyd Sheen