So here is what I was talking about, I created a very basic BAQ just hitting the Erp.InvcHead Table:
I then created a BAQ Report and added 2 Sort Options to it…
When I test the BAQ I get the following Objects created in the Reporting DB
taking this one step further, i can see my sort options in the BAQReportParameter table
Now go grab the RDL and take a look at the Dynamic SQL Query
It should be something similar to the following (YES I FORMAT MY SQL FROM ONE LINE TO MULTILINE) :
=“SELECT [InvcHead_Company]
,[InvcHead_InvoiceSuffix]
,[InvcHead_GroupID]
,[InvcHead_InvoiceNum]
,[InvcHead_InvoiceType]
,[InvcHead_OrderNum]
,[InvcHead_CustNum]
,[InvcHead_InvoiceDate]
,[InvcHead_DueDate]
,[InvcHead_InvoiceAmt]
,[InvcHead_SalesRepList]
FROM dbo.[BAQReportResult_” + Parameters!TableGuid.Value + “]”
I recommend changing your SQL statement to something like this:
="
DECLARE
@SQL VARCHAR(2000)
DECLARE
@SORT VARCHAR(200)
SELECT @SQL = ‘’, @SORT = ‘’
SELECT @SORT = SortFields from [dbo].[BAQReportParameter_" + Parameters!TableGuid.Value + “]
SET @SQL = ’
SELECT [InvcHead_Company]
,[InvcHead_InvoiceSuffix]
,[InvcHead_GroupID]
,[InvcHead_InvoiceNum]
,[InvcHead_InvoiceType]
,[InvcHead_OrderNum]
,[InvcHead_CustNum]
,[InvcHead_InvoiceDate]
,[InvcHead_DueDate]
,[InvcHead_InvoiceAmt]
,[InvcHead_SalesRepList]
FROM dbo.[BAQReportResult_” + Parameters!TableGuid.Value + "] ’
IF LEN(@SORT) > 0
BEGIN
SET @SORT = ’ ORDER BY '+ @SORT
EXEC (@SQL + @SORT)
END
ELSE
BEGIN
EXEC (@SQL)
END "
Although all of our solutions will work for you, I feel like the more processing you can do on the SQL side the more optimized your reports will be, if you have to populate multiple tablix… (how the heck do we make this plural?) controls and then suppress them on parameters, well SSRS still has to do all that work, this way you get one result set regardless of what sort options you choose.