Add constraints to XML data type columns

          

Add constraints to XML data type columns

<<Previous   Next>>

You can add constraints to XML data type columns. Illustrate with an example - March 12, 2009 at 14:00 PM by Amit Satpute

You can add constraints to XML data type columns. Illustrate with an example 

Constraints can be specified for typed or untyped xml data type columns.

However, you cannot use the XML data type methods when you specify constraints.

xml data type not supported for the following column and table constraints:

PRIMARY KEY/ FOREIGN KEY
UNIQUE
COLLATE
RULE

An alternative to using constraints is to create a wrapper, user-defined function to wrap the xml data type method and specify user-defined function in the check constraint as shown in the following example

CREATE FUNCTION myfunc1(@var xml) returns bit
AS BEGIN
RETURN @var.exist('/ProductDescription/@ProductID')
END
GO 

<<Previous   Next>>
 



Write your comment - Share Knowledge and Experience


 

 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring