Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Optional parameters

$
0
0

I have a query that I built using BIDS query builder.  I have two sets of parameters (ProjectStart/End and PrDatefrom/To).  I want to allow the user to fill in one only set of the parameters (either search by project range or production date range) or all parameters if they want.  How do I modify my query to use the parameters only when they are available and ignore them when they are null? I'm using SQL2005

SELECT        *
 FROM            ProductionRequest AS PR INNER JOIN
 ProductionRequest_Reports AS REP ON PR.ID = REP.ProductionRequest_ID INNER JOIN
  Projects AS P ON PR.Project_No = P.ProjectNo INNER JOIN
 Reports AS R ON P.ProjectID = R.ProjectID AND REP.Report_ID = R.ReportTypeID INNER JOIN
ReportDetails AS RD ON R.ReportID = RD.ReportID INNER JOIN
SHPOLtrFindingOfEffect AS SF ON RD.FindingofEffect = SF.LtrID
WHERE        (PR.Project_No >= @ProjectStart) AND (PR.Project_No <= @ProjectEnd) AND (REP.Report_ID = 4) AND (REP.ElecFinal_Num <> 0) AND  (CONVERT(DATETIME, REP.ElecFinal_PRDate) >= @PRDateFrom) AND (CONVERT(DateTime, REP.ElecFinal_PRDate) <= @PRDateTo)


Milissa Hartwell


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>