Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Subreport and drill down using stored procedures

Author  Topic 

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2010-03-26 : 09:18:46
I have a parameterized report that uses a stored procedure and it works fine. It is a detail report. I understand that I can create a summary report and call the detail report from that allowing a drill down. I actually have done one before.

But I did it with a SQL dataset. I am now using stored procedures. I guess my question is this: How do I pass the parameter from one to the other. (I actually think I can handle the report part, but not the stored procedure)? I am actually intending to use in the summary (calling) report:
AppID
AppName, (only on AppID per line)
Count(AppName) (the number of this AppID in the data)

Main detailed report (the called report)
AppID, (many lines with the same AppID
AppName (many lines with the same AppName,
Detail1,
Detail2,
etc.

Here is the SQL for the detail report's stored procedure which is used as the report's dataset:
USE [SoftwareReporting]
GO

/****** Object: StoredProcedure [dbo].[sp_ReportBasic] Script Date: 03/26/2010 09:10:23 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[sp_ReportBasic]
@AppName VARCHAR(255) = NULL,
@WkstnName VARCHAR(128) = NULL,
@EmployeeID VARCHAR(255) = NULL,
@PAYROLL_CO_num VARCHAR(4) = NULL,
@PAYROLL_RC_num VARCHAR(7) = NULL,
@MANAGER_EMPLOYEE_ID VARCHAR(255) = NULL
AS
BEGIN
SELECT v_CommonApp.AppName
, v_SMSAppData.[Version]
, v_SMSAppData.WkstnName
, SMS_Hardware.EmployeeID
, ePeople_feed.NAME
, ePeople_feed.PAYROLL_CO_num
, ePeople_feed.PAYROLL_RC_num
, ePeople_feed.EMAIL_ADDRESS
, ePeople_feed.PHONE_NUMBER
, ePeople_feed.MANAGER_EMPLOYEE_ID
, ePeople_feed.MANAGER_NAME
, ePeople_feed.MANAGER_PHONE
FROM v_SMSAppData
LEFT JOIN v_CommonApp ON v_SMSAppData.appID = v_CommonApp.AppID
LEFT JOIN SMS_Hardware ON v_SMSAppData.WkstnName = SMS_Hardware.wksname
LEFT JOIN ePeople_feed ON SMS_Hardware.EmployeeID = ePeople_feed.EMPLOYEE_ID
WHERE (@AppName IS NULL OR AppName LIKE '%' + @AppName + '%')
AND (@WkstnName IS NULL OR WkstnName LIKE '%' + @WkstnName + '%')
AND (@EmployeeID IS NULL OR EmployeeID = @EmployeeID)
AND (@PAYROLL_CO_num IS NULL OR PAYROLL_CO_num = @PAYROLL_CO_num)
AND (@PAYROLL_RC_num IS NULL OR PAYROLL_RC_num = @PAYROLL_RC_num)
AND (@MANAGER_EMPLOYEE_ID IS NULL OR EmployeeID = @MANAGER_EMPLOYEE_ID)
ORDER BY v_CommonApp.AppName
END
GO
And here is what I have (not complete) for the summary report. I need help figuring out - I think I need outgoing parameters. The SQL for the detail works in the grid. I just don't know how to pass it to the other:
CREATE PROCEDURE sp_InstalledAppNamesAndCounts 
-- Add the parameters for the stored procedure here
-- These will need to be changed, I am sure.
@p1 Varchar(255) = NULL,
@p2 int = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
-- These will need to be changed, I am sure.
-- SELECT @P1, @P2
SELECT v_CommonApp.AppName, COUNT(v_SMSAppdata.appID) AS CountOfApps
FROM v_CommonApp
LEFT JOIN v_SMSAppData ON v_SMSAppData.appID = v_CommonApp.AppID
GROUP BY v_CommonApp.AppName
HAVING COUNT(v_SMSAppData.AppID) > 0
ORDER BY v_CommonApp.AppNameEND
GO

Some of the code above (the parameters in the second script) are from the template generator, but I don't know how to use them.
Thank you for any help.

Duane

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-27 : 03:37:08
i think what you need to do is to use the summary proc for your summary report and then from summary report pass the value of AppName to your detail report which calls and passes this to detail report and gets the data corresponding to app and displays you result

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2010-03-29 : 11:33:02
Thank you for your response - I kind of thought I needed to pass parameters, but wasn't sure since you map them when you create the subreport. I suppose I need output parameters in the summary (calling) report. Could you, or someone explain to me how to create these for this report? I have been looking high and low but can't find it. I also don't know where to place the subreport on the summary report. Do I make a separate column and put it in the detail row for that column? Or in the aggregate group row? Or do I put it in the AppName field on the detail row or group row? or is there some other spot. The tutorials aren't very clear, either.
Her is some code I have tried for the summary (if you could help me with the parameters on this, maybe I will understand better. Thanks again:
ALTER PROCEDURE [dbo].[sp_InstalledAppNameCount]
AS
BEGIN
SELECT v_CommonApp.AppID
, v_CommonApp.AppName
, (COUNT(v_SMSAppdata.appID)) As AppCount
FROM v_CommonApp
LEFT JOIN v_SMSAppData ON v_SMSAppData.appID = v_CommonApp.AppID
GROUP BY v_CommonApp.AppID, v_CommonApp.AppName
HAVING COUNT(v_SMSAppData.AppID) > 0
ORDER BY v_CommonApp.AppName
END


Duane
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-29 : 12:30:55
i cant understand why you want to use output params in summary to pass value to subreport. you can just return a resultset from summary and then use fields collection to get value of relevant fields to be passed to subreport. Unless I'm missing something here, this is a very straightforward thing to do.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2010-03-29 : 12:58:55
I am not sure how to do what you're saying. I must have mental block on this one. I don't have to use output parameters. I guess I just don't understand how to do it either way.

Duane
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-29 : 13:02:20
quote:
Originally posted by duanecwilson

I am not sure how to do what you're saying. I must have mental block on this one. I don't have to use output parameters. I guess I just don't understand how to do it either way.

Duane


are you showing the fields to be passed to subreport in your summary? or are they available in your dataset in summary/parameter?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2010-03-29 : 13:18:46
Yes, I am showing them. It is just the AppName and then I have the count(AppID) which is an aggregate sum of how many of each type of AppName is in the detail records. For example, there may be 100,000 users of Winzip, so there will be a row in the summary report with Winzip, 100,000. So the summary report shows just those 2 columns and if works when I run it. It has about 60 lines with the + mark below the AppName. But, depending on what I do, when I click the plus +, I either get an error right on the report saying the data cannot be displayed, or the whole thing hangs.

Duane
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-29 : 13:20:07
quote:
Originally posted by duanecwilson

Yes, I am showing them. It is just the AppName and then I have the count(AppID) which is an aggregate sum of how many of each type of AppName is in the detail records. For example, there may be 100,000 users of Winzip, so there will be a row in the summary report with Winzip, 100,000. So the summary report shows just those 2 columns and if works when I run it. It has about 60 lines with the + mark below the AppName. But, depending on what I do, when I click the plus +, I either get an error right on the report saying the data cannot be displayed, or the whole thing hangs.

Duane


what you need to do is pass value of Fields!AppName.value as parameter for subreport and then render it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -