dbTalk Databases Forums  

Select with a Where that looks up in a XML column... Possible?

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Select with a Where that looks up in a XML column... Possible? in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ThunderMusic
 
Posts: n/a

Default Select with a Where that looks up in a XML column... Possible? - 05-10-2007 , 05:08 PM






Hi,
We have a serie of objects stored in the database as xml (ex: MyClass is
stored in the table MyClasses in the field XML_MyClassObj which contains the
an instance of the class serialized to XML). We did that because it was
easier to serialize everything and send it as XML than to build a 25-30
table structure that would become unmanageable.

Unfortunately, a problem arose today. This object uses some other object in
which we must add a method that would break the first object (the one that
is stored in the DB). The question is : Is it possible to do a Select that
would look in the XML_MyClassObj field and tell me if there is an object (of
the second type) with the ID equal to some determined ID we have?

Let's say

MyType1 --instance--> MyObject1--> Uses Obj2Child(MyObject2)-->ID=2;
MyType2 --instance--> MyObject2--> ID=2;

I take the MyObject2 and delete it. MyObject1 then become invalid, but how
can I retrieve that MyObject1 is using MyObject2? Let's remember that
MyObject1 is serialized in XML and is stored in a field in a table.

Is it possible? if so, how?

Thanks

ThunderMusic



Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: Select with a Where that looks up in a XML column... Possible? - 05-11-2007 , 03:59 PM






On Thu, 10 May 2007 18:08:02 -0400, ThunderMusic wrote:

(snip)
Quote:
Is it possible? if so, how?
Hi ThunderMusic,

Yes, I think that this is possible, using XQuery to query the XML data
in the XML column. However, the only thing I know of XQuery is that it
exists :-)

You should repost your question in microsoft.public.sqlserver.xml,
preferably with some sample data and expected results. You'll probably
find some XQuery expert to help you there.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.