Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table field design

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-10-14 : 06:43:34
An xml file is to be exported into a sql server table.
The contents of the xml file is something like:

<persons>
<person>
<firstname>
<value>john</value>
<value>jo</value>
<value>jack</value>
<firstname>
</person>
<person>
<firstname>
<value>mike</value>
</firstname>
</person>
<person>
<firstname></firstname>
</person>
</persons>

Question:
Should there be an xml datatype field to hold the firstname(s) ?
Notice that the firstname for a person can be repeated.
I can add several records, i.e. one for each firstname but I thought may be an xml field is better.
What do you think?
Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-14 : 08:30:55
you want store nodes including value or values alone?
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-10-14 : 09:08:14
Hi,
I am thinking as follows:
for record 1: in the xml field to have :
<firstname>
<value>john</value>
<value>jo</value>
<value>jack</value>
<firstname>

for record to to have
<firstname>
<value>mike</value>
</firstname>

for record three to have:
<firstname></firstname>
or may be have it as empty.

and so forth...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-14 : 13:31:14
then make column type as xml and use xmldoc.query() function to get nodes onto each record column value.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-10-15 : 03:46:45
Ok, thanks
Go to Top of Page
   

- Advertisement -