Categorized | database

Tags :

Insert xml data into SQL Server

XML is one of the data types in SQL Server 2005 and 2008.It is considered as one of the significant changes introduced in SQL Server 2005.In the previous versions, storing and retrieving XML data were possible but it was not as easy and extensible as it is in the current version. The XML data type lets the user to store XML data in the SQL Server database. In this article we will be discussing how to store, retrieve and query XML data.

Let’s now take a look at an example. This example demonstrates how to create a table that contains an XML column. We will also insert some records into the table.

1. Create table with XML column

Create table Product(ProductID int,ProductName varchar(50),ProductDetails XML)

2. Insert valid XML data into the table:

Insert into Product values(1,’Parker‘,’501,Pen, Parker,$500‘)

3. We can also create variables of XML type.

Declare @x xml
SET @x =’501,Pen, Parker,$500
Insert into Product values(1,’Parker‘,@x)

1 Comments For This Post

  1. pinkz Says:

    What are the words … super, wonderful phrase

Leave a Reply


rss_32 twitter_32 facebook_32 linkedin_32 stumbleupon_32 friendfeed_32 google_32

Information

  • Premium News Home
  • Designed by Adii
  • Log in
  • Powered by Wordpress
  • Entries RSS
  • Comments RSS
Facebook Like Button for Dummies