I have the following stored procedure:
ALTER PROCEDURE [dbo].[Provider]
(@strPro varchar(200))
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT *
FROM [db1].[dbo].[table1]
WHERE [Name] = @strPro
END
I have a dropdownlist which will have the following entry:
All People
John D.
Mike K.
Alan H.
Paul Q.
How can I modify the stored procedure so that if the user selects All People the WHERE statement will be a LIKE instead of a = sign
Example:
ALTER PROCEDURE [dbo].[Provider]
(@strPro varchar(200))
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT *
FROM [db1].[dbo].[table1]
if @strPro = 'All People'
BEGIN
WHERE [Name] LIKE '%'
END
ELSE
BEGIN
WHERE [Name] = @strPro
END
END