I would like to create an SP that will return all Country strings if CountryID not specified as a parameter. That's how I thought it might work, but he doesn't like it.
ALTER PROCEDURE [dbo].[usp_return_countries] @CountryID AS INT = 0 AS BEGIN SELECT * FROM Countries WHERE Active = 1 IF @CountryID > 0 BEGIN AND @CountryID = CountryID END END
thanks
PS I thought there might be a better way than just repeating the entire SELECT statement based on the specified condition.
David source share