Databases Reference
In-Depth Information
keys of the records to be updated and the data to be inserted is needed. In this first step,
SQL Server may read the table to be updated just like in any other SELECT statement.
In the second step, the update operations are performed, including updating indexes,
validating constraints and executing triggers. The update operation will fail and roll back
if it violates a constraint.
Let me start with an example of a very simple update operation. Inserting a new record
on the Person.CountryRegion table using the next query creates a very simple plan, as
shown in Figure 6-1.
INSERT INTO Person . CountryRegion ( CountryRegionCode , Name ) VALUES ( 'ZZ' , 'New
Country' )
Listing 6-1.
Figure 6-1: An insert example.
However, the same scenario gets complicated very quickly when you try to delete the
same record by running the next statement, as shown on the plan in Figure 6-2.
DELETE FROM Person . CountryRegion
WHERE CountryRegionCode = 'ZZ'
Listing 6-2.
Search WWH ::




Custom Search