J
John
Hi
My problem is that I have three parameters is a stored procedure and all of
them optional. I can't think of avoiding writing a sub-sp for every
combination of provided and not provided parameters except to use 'like' as
below. I suspect that this may not have good performance compared to an
exact comparisoon (=). Is there a better to handle three parameters where
any combination of them could be optional? I am using the following sp;
CREATE PROCEDURE [dbo].[MyProc]
@Param1 varchar(50) ='',
@Param2 varchar(50) ='',
@Param3 varchar(50) =''
AS
SET NOCOUNT ON;
SELECT Col1, Col2, Col3
FROM MyTable
WHERE (Col1 like @Param1+ '%') AND (Col2 like @Param2+ '%') AND (Col3 like
@Param3+ '%')
Thanks
Regards
My problem is that I have three parameters is a stored procedure and all of
them optional. I can't think of avoiding writing a sub-sp for every
combination of provided and not provided parameters except to use 'like' as
below. I suspect that this may not have good performance compared to an
exact comparisoon (=). Is there a better to handle three parameters where
any combination of them could be optional? I am using the following sp;
CREATE PROCEDURE [dbo].[MyProc]
@Param1 varchar(50) ='',
@Param2 varchar(50) ='',
@Param3 varchar(50) =''
AS
SET NOCOUNT ON;
SELECT Col1, Col2, Col3
FROM MyTable
WHERE (Col1 like @Param1+ '%') AND (Col2 like @Param2+ '%') AND (Col3 like
@Param3+ '%')
Thanks
Regards