|
Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original.
|
Traducción
Original
|
SET FORCEPLAN (Transact-SQL)
USE AdventureWorks2012; GO -- Make sure FORCEPLAN is set to OFF. SET SHOWPLAN_TEXT OFF; GO SET FORCEPLAN OFF; GO SET SHOWPLAN_TEXT ON; GO -- Example where the query plan is not forced. SELECT p.LastName, p.FirstName, v.Name FROM Person.Person AS p INNER JOIN HumanResources.Employee AS e ON e.BusinessEntityID = p.BusinessEntityID INNER JOIN Purchasing.PurchaseOrderHeader AS poh ON e.BusinessEntityID = poh.EmployeeID INNER JOIN Purchasing.Vendor AS v ON poh.VendorID = v.BusinessEntityID; GO -- SET FORCEPLAN to ON. SET SHOWPLAN_TEXT OFF; GO SET FORCEPLAN ON; GO SET SHOWPLAN_TEXT ON; GO -- Reexecute inner join to see the effect of SET FORCEPLAN ON. SELECT p.LastName, p.FirstName, v.Name FROM Person.Person AS p INNER JOIN HumanResources.Employee AS e ON e.BusinessEntityID = p.BusinessEntityID INNER JOIN Purchasing.PurchaseOrderHeader AS poh ON e.BusinessEntityID = poh.EmployeeID INNER JOIN Purchasing.Vendor AS v ON poh.VendorID = v.BusinessEntityID; GO SET SHOWPLAN_TEXT OFF; GO SET FORCEPLAN OFF; GO
