Database Reference
In-Depth Information
Figure 25-14.
Extended Events output showing errors raised by a SQL workload
From the Extended Events output in Figure
25-14
, you can see that the two errors I intentionally generated
occurred.
error_reported
•
missing_join_predicate
The
error_reported
error was caused by the
INSERT
statement, which tried to insert data that did not pass
the referential integrity check; namely, it attempted to insert
Productld = 42
when there is no such value in the
Production.Product
table. From the
error_number
column, you can see that the error number is 547. The message
column shows the full description for the error. It's worth noting, though, that error_reported can be quite chatty with
lots of data returned and not all of it useful.
The second type of error,
missing_join_predicate
, is caused by the
SELECT
statement.
•
SELECT p.[Name]
,c.
[Name]
FROM Production.Product AS p
,Production.ProductSubCategory AS c;
GO
If you take a closer look at the
SELECT
statement, you will see that the query does not specify a
JOIN
clause
between the two tables. A missing join predicate between the tables usually leads to an inaccurate result set and a
costly query plan. This is what is known as a
Cartesian join,
which leads to a
Cartesian product,
where every row from
one table is combined with every row from the other table. You must identify the queries causing such events in the