Sunday, March 22, 2015
There times when you have to store data as XML in a SQL Server database table. In this blog we will go over how to store XML as data in SQL Server. There's an xml data type in SQL Server that we can use to store XML data.
Example: Create a database table that contains a column to store XML data using the xml data type
If you look at the "Book" column for the table "Books" you will see that it has a data type of XML
Now that we have our table set up, we can insert XML data to into the table
In the example above we CAST the type to XML first before we insert the data into the Books column because we want to make sure that the data we are inserting into the column is a well-formed XML data. If you query the table now you will see that there's one record with XML data in the "Book" column
Example: Create a database table that contains a column to store XML data using the xml data type
CREATE TABLE Books ( Id INT NOT NULL IDENTITY(1,1) PRIMARY KEY, Book XML NOT NULL );
If you look at the "Book" column for the table "Books" you will see that it has a data type of XML
Now that we have our table set up, we can insert XML data to into the table
INSERT INTO Books(Book) VALUES( CAST ( '<book> <author>Bill King</author> <title>ACME Consulting: An Inside Look</title> <publisher>ACME Publishing</publisher> <language>Swahili</language> </book>' AS XML));
In the example above we CAST the type to XML first before we insert the data into the Books column because we want to make sure that the data we are inserting into the column is a well-formed XML data. If you query the table now you will see that there's one record with XML data in the "Book" column
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
Mua vé máy bay tại Aivivu, tham khảo
ReplyDeleteVe may bay di My
bay về việt nam từ mỹ
đặt vé từ nhật về việt nam
ve may bay tư duc ve viet nam
vé máy bay từ Toronto về việt nam
vé máy bay hàn quốc hà nội
chuyen bay chuyen gia ve viet nam