TechNet
Export (0) Print
Expand All

Simulating an IF-WHILE EXISTS Statement in a Natively Compiled Module

 

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2014)yesAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Natively compiled stored procedures do not support the EXISTS clause in conditional statements such as IF and WHILE.

The following example illustrates a workaround using a BIT variable with a SELECT statement to simulate an EXISTS clause:

DECLARE @exists BIT = 0  
SELECT TOP 1 @exists = 1 FROM MyTable WHERE …  
IF @exists = 1  

Migration Issues for Natively Compiled Stored Procedures
Transact-SQL Constructs Not Supported by In-Memory OLTP

Community Additions

ADD
Show:
© 2016 Microsoft