SET NOEXEC (Transact-SQL)SET NOEXEC (Transact-SQL)

ESTE TEMA SE APLICA A:síSQL Server (a partir de 2008)síAzure SQL DatabasenoAzure SQL Data Warehouse noAlmacenamiento de datos paralelos THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)yesAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Compila cada consulta, pero no la ejecuta.Compiles each query but does not execute it.

Icono de vínculo de tema Convenciones de sintaxis de Transact-SQLTopic link icon Transact-SQL Syntax Conventions

SintaxisSyntax


SET NOEXEC { ON | OFF }  

ComentariosRemarks

Cuando SET NOEXEC es ON, SQL ServerSQL Server compila cada lote de instrucciones Transact-SQLTransact-SQL pero no las ejecuta.When SET NOEXEC is ON, SQL ServerSQL Server compiles each batch of Transact-SQLTransact-SQL statements but does not execute them. Cuando SET NOEXEC es OFF, todos los lotes se ejecutan después de su compilación.When SET NOEXEC is OFF, all batches are executed after compilation.

La ejecución de instrucciones en SQL ServerSQL Server tiene dos fases: compilación y ejecución.The execution of statements in SQL ServerSQL Server has two phases: compilation and execution. Esta opción es útil para hacer que SQL ServerSQL Server valide la sintaxis y los nombres de objeto del código Transact-SQLTransact-SQL durante la ejecución.This setting is useful for having SQL ServerSQL Server validate the syntax and object names in Transact-SQLTransact-SQL code when executing. También es útil para depurar instrucciones que normalmente serían parte de un lote de instrucciones mayor.It is also useful for debugging statements that would generally be part of a larger batch of statements.

La opción SET NOEXEC se establece en tiempo de ejecución, no en tiempo de análisis.The setting of SET NOEXEC is set at execute or run time and not at parse time.

PermissionsPermissions

Debe pertenecer al rol public.Requires membership in the public role.

EjemplosExamples

El ejemplo siguiente utiliza NOEXEC con una consulta válida, una consulta con un nombre de objeto no válido y una consulta con sintaxis incorrecta.The following example uses NOEXEC with a valid query, a query with an object name that is not valid, and a query with incorrect syntax.

USE AdventureWorks2012;  
GO  
PRINT 'Valid query';  
GO  
-- SET NOEXEC to ON.  
SET NOEXEC ON;  
GO  
-- Inner join.  
SELECT e.BusinessEntityID, e.JobTitle, v.Name  
FROM HumanResources.Employee AS e   
   INNER JOIN Purchasing.PurchaseOrderHeader AS poh  
   ON e.BusinessEntityID = poh.EmployeeID  
   INNER JOIN Purchasing.Vendor AS v  
   ON poh.VendorID = v.BusinessEntityID;  
GO  
-- SET NOEXEC to OFF.  
SET NOEXEC OFF;  
GO  

PRINT 'Invalid object name';  
GO  
-- SET NOEXEC to ON.  
SET NOEXEC ON;  
GO  
-- Function name uses is a reserved keyword.  
USE AdventureWorks2012;  
GO  
CREATE FUNCTION dbo.Values(@BusinessEntityID int)  
RETURNS TABLE  
AS  
RETURN (SELECT PurchaseOrderID, TotalDue  
   FROM dbo.PurchaseOrderHeader  
   WHERE VendorID = @BusinessEntityID);  

-- SET NOEXEC to OFF.  
SET NOEXEC OFF;  
GO  

PRINT 'Invalid syntax';  
GO  
-- SET NOEXEC to ON.  
SET NOEXEC ON;  
GO  
-- Built-in function incorrectly invoked.  
SELECT *  
FROM fn_helpcollations;  
-- Reset SET NOEXEC to OFF.  
SET NOEXEC OFF;  
GO  

Vea tambiénSee Also

Instrucciones SET (Transact-SQL) SET Statements (Transact-SQL)
SET SHOWPLAN_ALL ( Transact-SQL ) SET SHOWPLAN_ALL (Transact-SQL)
SET SHOWPLAN_TEXT ( Transact-SQL )SET SHOWPLAN_TEXT (Transact-SQL)