How to apply defaults constraint to an XML data type column

          

How to apply defaults constraint to an XML data type column

<<Previous   Next>>

How to apply defaults constraint to an XML data type column - March 09, 2009 at 11:00 AM by Amit Satpute

Explain with an example how to apply defaults constraint to an XML data type column. 

An xml column type can be assigned a default XML instance in a table.

It can be done in 2 ways:

1.by using an XML constant

Syntax:
CREATE TABLE T (XmlColumn xml default N'<element1/><element2/>')

2.by using an explicit cast to the xml type.

Syntax:
CREATE TABLE T (XmlColumn xml
                default CAST(N'<element1/><element2/>' AS xml))

SQL Server also supports NULL and NOT NULL constraints on columns of xml type.

Example:
CREATE TABLE T (XmlColumn xml NOT NULL) 

<<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