Is is possible to use CASE in a Where clause? I'm trying to find an easier way to do the following. This is in a Stored Procedure I'm writing, rather than having 15 Select statements, is there some way I can have a dynamic where clause and just use 1 statement?
Hope This Helps!
ECAR
ECAR Technologies
"My work is a game, a very serious game." - M.C. Escher
Code:
IF @Type = 'Sales'
BEGIN
Select IncidentID, IncidentDate, Customer, JobName, JobNumber
From dbo.Incidents
Where Sales = 1
Order By IncidentID
END
IF @Type = 'Quality'
BEGIN
Select IncidentID, IncidentDate, Customer, JobName, JobNumber
From dbo.Incidents
Where Quality = 1
Order By IncidentID
END
IF @Type = 'Production'
BEGIN
Select IncidentID, IncidentDate, Customer, JobName, JobNumber
From dbo.Incidents
Where Production = 1
Order By IncidentID
END
.....Several More of the same type SQL statements...
Hope This Helps!
ECAR
ECAR Technologies
"My work is a game, a very serious game." - M.C. Escher