473,503 Members | 12,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To create table in SQL by reading the values from XML file

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.

Mar 15 '07 #1
4 2311
Access does this right out of the box

you can do this for Access MDB or Access ADP (100% SQL Server)

RIGHT-CLICK IMPORT
On Mar 15, 12:16 am, "Priya" <priyavaithianat...@gmail.comwrote:
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.

Mar 15 '07 #2
On Mar 15, 3:16 am, "Priya" <priyavaithianat...@gmail.comwrote:
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.
It's definitely possible, the two parts you need to figure out is how
to write the Create Table Sql statement and then how to parse the xml
file into that. I'm afraid I can't be too much help on the query side,
but everything you need for the Xml parsing resides in the System.Xml
namespace. Perhaps you could provide a short version of the Xml file
if you need some help parsing it. By the which database are you using?
I'm guessing Sql server?

Thanks,

Seth Rowe

Mar 15 '07 #3

"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

Mar 16 '07 #4
On Mar 15, 5:01 pm, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
On Mar 15, 3:16 am, "Priya" <priyavaithianat...@gmail.comwrote:
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.

It's definitely possible, the two parts you need to figure out is how
to write the Create Table Sql statement and then how to parse the xml
file into that. I'm afraid I can't be too much help on the query side,
but everything you need for the Xml parsing resides in the System.Xml
namespace. Perhaps you could provide a short version of the Xml file
if you need some help parsing it. By the which database are you using?
I'm guessing Sql server?

Thanks,

Seth Rowe
I dont have any particular database specification. I have an interface
which can connect to any database. So I want this XML parsing also to
be common. My XML spec
<Tables>
<Table Name="Employee">
<Fields>
<Field Name="EmployeeID">
<Datatype>Varchar</Datatype>
<Length>30</Length>
<AllowNull>False</AllowNull>
<PrimaryKey>PK_EmployeeID</PrimaryKey>
</Field>
<Field Name="EmployeeName">
...........
</Field>
</Fields>
<TableConstraints>
<ForeignKey Name="FK_Name">
<RefTable>TableName</RefTable>
<RefColumn>ColumnName</RefColumn>
<FieldName>ColumnName</FieldName>
</ForeignKey>
</TableConstraints>
</Table>
</Tables>
I need to parse an XML file similar to this and then create the table
using the interface that has the create table method. Should I use the
XML node and Child node concepts in the System.XML namespace to do
this. Or is there a better method to parse the XML file?

Thanks
Mar 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3491
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
6
18816
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at...
2
13905
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
7
8821
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
5
1895
by: Mountain Bikn' Guy | last post by:
How would I do this? public sealed class UtilityClass { public static MyObject Object1;//see note below about importance of static object names in this class public static MyObject Object2;...
2
6396
by: mpriem | last post by:
Hi, I am trying to create a webapplication which reads a Xml Document and dynamically creates tables containing the values. The Xml Document is created by a windows service I programmed. So if I...
4
3307
by: Jan | last post by:
Have an SQL create/import script. Running this on SQL would make it create a table with some values. Can Access2003 somehow use such and SQL script? I went into SQL query view to try it out, but...
2
2220
by: GarryJones | last post by:
(I am sorry if this is the wrong group for this posting, I cant find a group on usenet for phpmyadmin, but maybe someone would be nice enough to answer me anyway....) I need to import data into...
15
5237
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.