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
 General SQL Server Forums
 New to SQL Server Programming
 How To Save XML File To A DataBase

Author  Topic 

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 01:09:04
Hi Friends ,
How To Save A Whole XML Into DataBase? Consider That I Have a XML File Named MyXML.xml,Then I have To Store This XML To The DataBase.Can Anyone Please Help To Solve This ....It is Possible To Save The Whole XML Into A DataBase Table By Declaring That Particular Column's Variable Type As XML ...I Want To Know How To Save My XML File Into A Location In DataBase Other Than Table And How To Retrieve It..Expecting A Quick And Clear Reply...
Regards And Thanks ,
Titt.S

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-09 : 01:20:52
Other than table? What do you mean by that?


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 01:57:00
Thanks For Your Reply..Im A NewBie To SQL DataBases..I Just Want To Know Is It Possible To Store XML Just Like We Are Saving Query's In Views...Sorry If Im Wrong...So Saving Some Datas In DataBase Means That Saving It To Tables ????

Thanks And Regards,
Titti.S
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-09 : 02:16:55
Yes you can.
Read more about Filestream for SQL 2008 in BOL.



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 02:28:19
Hi Thanks For Your Reply Idera..Can You Give Me A Clear Picture.....Is It SomeThing Like Hosting A XML TO DataBase..And Can I See Where My XML File Is Stored In DataBase..??

Thanks And Regards,
Titti.S
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-09 : 02:39:26
Have a look here

http://www.sqlservercentral.com/articles/SQL+Server+2008/64088/


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 03:37:07
Well Thanks Again For Your Kind Reply...Can You Tell Me Which Way Is More Faster?? ie) To Storing And Accessing XML In
DataBase Table Or In FileStream !!..Can You Post Me An Example .....??
Go to Top of Page

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 07:38:23
Hi AnyOne There To Help Me Out...Please...

Thanks And Regards,
Titti.S


Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-09 : 07:58:10
quote:
Originally posted by TittiSkaria

Well Thanks Again For Your Kind Reply...Can You Tell Me Which Way Is More Faster?? ie) To Storing And Accessing XML In
DataBase Table Or In FileStream !!..Can You Post Me An Example .....??



What do u mean by XML in DB?
From your first post I am assuming that you have a xml file which you want to save it in the table.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 08:27:33
Hi Idera,
Actually I Need To Store My XML Into DataBase For Easy Retreiving The Datas When I Need It.I Have Just Saved My XML To DB Table Successfully..But I Want To Know Is There AnyOther Location Or Option Available For Saving My XML Other Than Table...Which Means In FileStream Or SomeWhere In DB.. Which is Better And Faster..To Save It In DB Table As Just Did Or To Save In FileStream ??????

Thanks And Regards,
Titti.S
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-09 : 08:39:19
Well it depends on how you want it.if you have physical xml files & want to save them then go filestream or else just use xml datatype to save xml in the table.

I would go for xml datatype & would add xml indexes to it for fast retrieval.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-09-09 : 11:01:28
If your XML files are under 2GB each you can store them in a column using the XML datatype. For example:
CREATE TABLE MyTable
(
MyXmlColumn XML
)
You can read more about using XML in SQL in BOL (Book Online).
Go to Top of Page

TittiSkaria
Starting Member

16 Posts

Posted - 2010-09-09 : 23:39:19
Hi Friends,
Thanks For Your Replies...Ok My XML Files Are Under 2GB,So Im Going With The Way Of Storing It In Table.Then Regarding FileStreams I Will Definitely Give It A Try..

Thanks And Regards,
Titti.S
Go to Top of Page

siliumang
Starting Member

1 Post

Posted - 2010-09-10 : 07:17:31
spam removed
Go to Top of Page

claudiu
Starting Member

2 Posts

Posted - 2010-11-23 : 19:14:53
Not sure if this topic is still open, but here is an awesome post: http://www.developer.com/db/article.php/3565996.

It basically saves the XML document inside a database table, in an XML type field. You can then use XQuery language to query the XML field and extract whatever data you want from your XML field. I tried that before, it works well, although kinda' slow, not sure if it's our inability to optimize it or something else.

Claudiu
Go to Top of Page

claudiu
Starting Member

2 Posts

Posted - 2010-11-23 : 19:18:22
Just realized, the URL is http://www.developer.com/db/article.php/3565996

Crazy dot at the end...

C.
Go to Top of Page
   

- Advertisement -