Wednesday, March 28, 2012

multityped column

Hi!
I have a typed xml column whith two schemas in the corresponding xml
schema collection (multityped column). Is there a simple way of
creating a new column, showing the name of the xml schema that each
row is typed to.
This is very useful to implement in cases of multiple versions of a
schema in a schema collection. Your application code could then more
easily apply schema specific logic.
I guess I could always create a computed column that uses a sql
function that figures it out, but since it seemes like a standard
problem, I first want to make sure there are no neat, built in, out of
the box solutions for this problem.
Thanks,
Paul
The easiest way to check is to use the namespace-uri() function on the
top-level elements in your XML column. There is no such built-in.
Best regards
Michael
<paululvinius@.hotmail.com> wrote in message
news:1179156961.804277.146930@.y80g2000hsf.googlegr oups.com...
> Hi!
> I have a typed xml column whith two schemas in the corresponding xml
> schema collection (multityped column). Is there a simple way of
> creating a new column, showing the name of the xml schema that each
> row is typed to.
> This is very useful to implement in cases of multiple versions of a
> schema in a schema collection. Your application code could then more
> easily apply schema specific logic.
> I guess I could always create a computed column that uses a sql
> function that figures it out, but since it seemes like a standard
> problem, I first want to make sure there are no neat, built in, out of
> the box solutions for this problem.
> Thanks,
> Paul
>
|||On 14 Maj, 21:58, "Michael Rys [MSFT]" <m...@.online.microsoft.com>
wrote:
> The easiest way to check is to use the namespace-uri() function on the
> top-level elements in your XML column. There is no such built-in.
> Best regards
> Michael
> <paululvin...@.hotmail.com> wrote in message
> news:1179156961.804277.146930@.y80g2000hsf.googlegr oups.com...
>
>
>
>
> - Visa citerad text -
Thanks!
I used a computed column like: "dbo.GetNamespaceUri(MyXmlColumn)". The
function uses xpath with the namespace-uri() function to determine the
namespace. I wasnt allowed to make the column persisted though because
its "non-deterministic".
This leaves us with a design choice:
If we use this solution, will it result in a noticable performance
impact? Maybe a insert/update trigger that fills the value is a more
performance friendly solution?
(We expect more queries than non-queries on this table)
|||Did you define the function as schema bound? That should make it
deterministic I think.
Also, you could promote the value out on insert instead of using triggers.
Best regards
Michael
<paululvinius@.hotmail.com> wrote in message
news:1179224729.491872.79810@.w5g2000hsg.googlegrou ps.com...
On 14 Maj, 21:58, "Michael Rys [MSFT]" <m...@.online.microsoft.com>
wrote:
> The easiest way to check is to use the namespace-uri() function on the
> top-level elements in your XML column. There is no such built-in.
> Best regards
> Michael
> <paululvin...@.hotmail.com> wrote in message
> news:1179156961.804277.146930@.y80g2000hsf.googlegr oups.com...
>
>
>
>
> - Visa citerad text -
Thanks!
I used a computed column like: "dbo.GetNamespaceUri(MyXmlColumn)". The
function uses xpath with the namespace-uri() function to determine the
namespace. I wasnt allowed to make the column persisted though because
its "non-deterministic".
This leaves us with a design choice:
If we use this solution, will it result in a noticable performance
impact? Maybe a insert/update trigger that fills the value is a more
performance friendly solution?
(We expect more queries than non-queries on this table)
|||On 20 Maj, 22:50, "Michael Rys [MSFT]" <m...@.online.microsoft.com>
wrote:
> Did you define the function as schema bound? That should make it
> deterministic I think.
> Also, you could promote the value out on insert instead of using triggers.
> Best regards
> Michael
> <paululvin...@.hotmail.com> wrote in message
> news:1179224729.491872.79810@.w5g2000hsg.googlegrou ps.com...
> On 14 Maj, 21:58, "Michael Rys [MSFT]" <m...@.online.microsoft.com>
> wrote:
>
>
>
>
>
>
>
> Thanks!
> I used a computed column like: "dbo.GetNamespaceUri(MyXmlColumn)". The
> function uses xpath with the namespace-uri() function to determine the
> namespace. I wasnt allowed to make the column persisted though because
> its "non-deterministic".
> This leaves us with a design choice:
> If we use this solution, will it result in a noticable performance
> impact? Maybe a insert/update trigger that fills the value is a more
> performance friendly solution?
> (We expect more queries than non-queries on this table)- Dlj citerad text -
> - Visa citerad text -
Thanks for all your help!
I think we will decide to promote the value out on insert, seems like
the "keep it simple and safe" -way to do it

No comments:

Post a Comment