Databases Reference
In-Depth Information
We will be using these two DMVs in several sections later in this chapter, and you should,
hopefully, come to see why they are very useful in providing additional insight into the
work being performed by the Query Optimizer.
Parsing and Binding
Parsing and binding are the first operations that SQL Server executes when you submit a
query to a database and, in the current version, they are performed by a component called
the Algebrizer.
Parsing
first makes sure that the T-SQL query has a valid syntax, and then
uses the query information to build a tree of relational operators. By that, I mean the
parser translates the SQL query into an algebra tree representation of logical operators,
which is called a parse tree.
Parsing only checks for valid T-SQL syntax, not for valid table or column names, which
are verified in the next phase:
binding
.
Parsing is similar to the parse functionality available in Management Studio (by clicking
the
Parse
button on the default toolbar) or the
SET PARSEONLY
statement. For example,
the following query will successfully parse on the
AdventureWorks
database, even when
the listed columns and table do not exist in said database.
SELECT
lname
,
fname
FROM
authors
Listing 5-7.
However, if you incorrectly write the
SELECT
or
FROM
keywords, SQL Server will return
an error message complaining about the incorrect syntax.