Update SQL Server database with Updategrams

You can use XML to transfer both data and commands. In this column I’ll show how you can update a database by means of XML commands sent over the HTTP protocol and, even more interesting, how to perform bulk uploads with these commands.

An updategram is a piece of XML data that contains information about how to modify data in a database, expressed as an insert, update, or delete operation of existing records. Consider the following updategram:

                           

The updg:sync element embeds the information that specifies how to manipulate data. Its child element, updg:before, contains information about the record that is going to be modified. In this particular case this information is missing, and the opening tag is immediately followed by the closing tag. Next, consider the updg:after element: the data in this tag represents an element named Employees, which in turn contains the FirstName and LastName attributes. This updategram will be converted into an INSERT command that will insert a new record and assign the specified values (“Nancy” and “Davolio”) to these fields. Here are two more examples that show how records can be deleted and updated.

The following updategram is equivalent to this DELETE statement

DELETE FROM Employees WHERE FirstName="Nancy" AND LastName="Fuller"               

The following updategram is equivalent to this UPDATE statement

UPDATE Employees SET Lastname="Fuller" WHERE EmployeeID=1      

########################################################

This tip has been originally published on Microsoft Italia’s web site.
It has been translated and re-published on VB2TheMax with the permission of Microsoft Italia.
You can find more tips like this one (in Italian) at http://www.microsoft.com/italy/sql/articoli

########################################################

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may