claracruz
asked on
Sql stored procedure help
hello experts,
I have the following stored procedure;-
SELECT *
FROM Records
WHERE
groupid = (@groupid)
and functionid LIKE (@functionid)
The thing is that sometimes, the query may not require to filter by groupid and functionid and will just need to do a sraight search like so;-
SELECT *
FROM Records
What's the best way to implement this...(and why?)
Many thanks
I have the following stored procedure;-
SELECT *
FROM Records
WHERE
groupid = (@groupid)
and functionid LIKE (@functionid)
The thing is that sometimes, the query may not require to filter by groupid and functionid and will just need to do a sraight search like so;-
SELECT *
FROM Records
What's the best way to implement this...(and why?)
Many thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
integer variables and column CAN take nulls.
ASKER
Sorry, both are integer values so can't take null (well as far as I know anyways). what would be the replacement for this line;-
WHERE ( groupid = @groupid or @groupid is null)
where groupid is an integer