Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Azure SQL Database
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;