I have a report which shows purchase indents over a period of time created by indentor. Here, @Name parameter is used to filter indentor. But, the problem is, if @Name parameter is blank then the report is returning null records. I want to show the report with all Indentors if nothing is selected in @Name filter. Below is the Query. I'm new to SQL.
SELECT INH.No_, INH.[Approved Date],
INH.Indentor, INL.No_ AS ItemCode,
INL.Description, INL.Description2,
INL.Req_Quantity, INL.[Unit of Measure],
PL.[Document No_], PH.[Order Date], PL.Quantity AS OrderedQuantity, PL.[Quantity Received]
FROM [Company$Indent Header] AS INH
INNER JOIN
[Company$Indent Line] AS INL
ON INH.No_ = INL.[Document No_]
INNER JOIN
[Company$Purchase Line] AS PL
ON INL.[Document No_] = PL.[Indent No_] AND INL.[Line No_] = PL.[Indent Line No_]
INNER JOIN
[Company$Purchase Header] AS PH
ON PL.[Document No_] = PH.No_
WHERE (INH.Indentor = @Name) AND (INL.No_ <> '') AND
(INH.[Approved Date] BETWEEN @StartDate AND @EndDate)
ORDER BY ItemCode