devxlogo

Update SQL Server database with Updategrams

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

See also  How College Students Can Shape the Future of Tech Responsibility

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

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist