Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Kiss the Middle-tier Goodbye with SQL Server Yukon : Page 3

Yukon's new XML support features cut out the middleman and allow you to deal with your data directly on the database tier. Learn how to use these features to improve your database app's performance and design.


advertisement
Loading the XML Datatype
How do you load XML data into the new XML datatype? With Yukon, you can convert string data to XML data implicitly or explicitly by using the T-SQL functions CAST and CONVERT. Take a look:

INSERT INTO Customers (ID, CustomerDocument) VALUES ( 1, '<Customer xmlns="http://www.csharp.at/Conferences/ 2004/02/ASPKonferenz" CustomerID="ALFKI" State="DE" Type="ISV"> Alfreds Futterkiste </Customer>' ) INSERT INTO Customers(ID, CustomerDocument) VALUES ( 2, CAST('<Customer xmlns="http://www.csharp.at/ Conferences/2004/02/ASPKonferenz" CustomerID="MSFT" State="WA" Type="ISV"> Microsoft Corporation </Customer>' AS xml) ) INSERT INTO Customers(ID, CustomerDocument) VALUES ( 3, CONVERT(xml, '<Customer xmlns="http://www.csharp.at/ Conferences/2004/02/ASPKonferenz" CustomerID="TT" State="AT" Type="ISV"> TechTalk </Customer>') )

You need to provide the target namespace in order to insert XML data to a typed XML datatype. Without the the target namespace, Yukon raises an exception and the data won't be inserted. This guarantees that all inserted XML data is validated and matches the provided XML schema.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap