CREATE PROC KRCityContacts
@city varchar(20) = NULL
AS
DECLARE @rowcount int
IF @city IS NOT NULL
BEGIN
SELECT CompanyName
FROM Customer
WHERE CompanyName IS NOT NULL
AND City = @city
UNION
SELECT CompanyName
FROM Supplier
WHERE City = @city
SET @rowcount = @@ROWCOUNT
IF @rowcount = 0
PRINT 'No Suppliers or Customers in the city of ' + @city
END
ELSE
PRINT 'Please enter a city.'
GO
EXEC KRCityContacts 'Greenville'
I just tried that, but it literally returns nothing. I want it to print a message, 'No Suppliers or Customers in the city of ' + @city, when no rows are returned, but that's not happening for some reason.