I have using the 'Customers' table from the Northwind database in this example
SELECT CompanyName, ContactName, ContactTitle FROM Customers
where CustomerID='XYZ'
-- Check if the first query returned results
-- If the ROWCOUNT is zero, run the other query
if @@ROWCOUNT = 0
BEGIN
SELECT CompanyName, ContactName, ContactTitle FROM Customers
where CustomerID='ALFKI'
END
No comments:
Post a Comment