xxxxxxxxxx
IF EXISTS (SELECT * FROM tblGLUserAccess WHERE GLUserName ='xxxxxxxx')
BEGIN
SELECT 1
END
ELSE
BEGIN
SELECT 2
END
xxxxxxxxxx
IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'your_table_name')
SELECT 'Table exists'
ELSE
SELECT 'Table does not exist'
xxxxxxxxxx
-- Checking if there are any orders with a specific product ID
IF EXISTS (
SELECT 1
FROM orders
WHERE product_id = 123
)
BEGIN
PRINT 'There are orders with product ID 123'
END
ELSE
BEGIN
PRINT 'No orders with product ID 123 found'
END