Share via


Binding Relational Data Inside XML Data

You can specify XML Data Type Methods against an xml data type variable or column. For example, the query() method (XML data type) executes the specified XQuery against an XML instance. When you construct XML in this manner, you may want to bring in a value from a non-XML type column or a Transact-SQL variable. This process is referred to as binding relational data inside XML.

To bind the non-XML relational data inside XML, the SQL Server Database Engine provides the following pseudo-functions:

You can use these functions with xml data type methods whenever you want to expose a relational value inside XML.

You cannot use these functions to reference data in columns or variables of the xml, CLR user-defined types, datetime, smalldatetime, text, ntext, sql_variant, and image types.

Also, this binding is for read-only purposes. That is, you cannot write data in columns that use these functions. For example, sql:variable("@x")="some expression" is not allowed.

See Also

Concepts

Sample XML Applications

Other Resources

xml Data Type Methods

Help and Information

Getting SQL Server 2005 Assistance