Skip to content

Tag Archives: xquery

Persisting Computed XML

It’s possible to define an XML column as a computed column. And in most cases I think it would make sense to persist the column to save doing all that work again. As Bob Beauchemin points out there’s a trick to doing it.

The first thing you need is a user defined scalar function to [...]

Detecting SQL NULL in XQuery

When using XQuery inside SQL Server the value of SQL variables and columns can be referenced using the sql:column and sql:variable functions respectively. When a SQL value is NULL you may want to mark the XML element as xsi:nil, like the following.

<event_data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

The semantic equivalent of SQL NULL in XQuery is an empty [...]