ousoonerjoe
Programmer
I'm having issues with SSRS failing to read the returning recordset. When executed in Query Analyzer, all returns exactly as expected. SSRS Returns nothing. In fact, in my testing it acts as if it will not run the EXECUTE command. The report is completed, just need the query to load at run-time. Any guidance is appreciated.
--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
Code:
[COLOR=blue]ALTER PROCEDURE[/color] cst_Rpt_Ncr_Summary(
@StartDate [COLOR=blue]DATETIME[/color] = [COLOR=red]'7/4/1776'[/color],
@EndDate [COLOR=blue]DATETIME[/color] = [COLOR=red]'12/31/2032'[/color],
@CauseId [COLOR=blue]INT[/color] = 0,
@IssueDept [COLOR=blue]INT[/color] = 0,
@ActionDept [COLOR=blue]INT[/color] = 0)
[COLOR=blue]AS[/color]
[COLOR=green]--============================================================================
-- Created By: xxxx - 11/19/2009
-- Purpose: Move away from using SELECT * statements in any application.
-- Migrate towards a better naming convention.
--============================================================================[/color]
[COLOR=blue]DECLARE[/color] @Sql [COLOR=blue]VARCHAR[/color](4000);
[COLOR=blue]DECLARE[/color] @ProcName [COLOR=blue]VARCHAR[/color](50);
[COLOR=blue]SET[/color] @ProcName = [COLOR=red]'cst_Rpt_Ncr_Summary'[/color];
[COLOR=blue]SET[/color] @Sql = [COLOR=red]''[/color];
[COLOR=blue]BEGIN TRY
BEGIN TRANSACTION[/color];
[COLOR=blue]INSERT INTO[/color] Audit(ProcName, CmdType, Statement, ExecFrom, RecordIdNum, Arg1, Arg2, Arg3)
[COLOR=blue]VALUES[/color](@ProcName, [COLOR=red]'REPORT'[/color], [COLOR=red]''[/color], [COLOR=red]''[/color], 0, @StartDate, @EndDate, @CauseId);
[COLOR=blue]COMMIT TRANSACTION[/color];
[COLOR=blue]SET[/color] @Sql = ([COLOR=red]'SELECT n.NonConformId, n.JobNum,
[IssueDept] = i.DeptName,
[Division] = d.DivName,
[Cause] = c.Descr,
[Status] = s.Descr,
[Description] = n.Description,
[Resolution] = n.Resolution,
[RecommendBy] = dbo.TRIM(pr.premp_first_n + '' '' + pr.premp_last_n),
[RecommendDate] = n.RecommendDate,
[ApprovedBy] = dbo.TRIM(pa.premp_first_n + '' '' + pa.premp_last_n),
[ApproveDate] = n.ApproveDate,
[ActionDept] = a.DeptName,
[CauseDesc] = n.CauseDesc,
[ResponsibleDept] = r.DeptName,
[QaApproval] = dbo.TRIM(pq.premp_first_n + '' '' + pq.premp_last_n),
[QaDate] = n.QaDate,
[CreateDate] = n.CreateDate
FROM NonConform n
LEFT JOIN Departments i ON n.IssuingDept = i.DeptId
INNER JOIN Division d ON n.Division = d.DivisionId
INNER JOIN NcrCause c ON c.NcrCauseId = n.Cause
INNER JOIN NcrStatus s ON s.NcrStatusId = n.Status
LEFT JOIN TmpPrEmp pr ON n.RecommendBy = pr.premp_num
LEFT JOIN TmpPrEmp pa ON n.ApprovedBy = pa.premp_num
LEFT JOIN Departments a ON n.ActionDept = a.DeptId
LEFT JOIN Departments r ON n.ResponsibleDept = r.DeptId
LEFT JOIN TmpPrEmp pq ON n.QaApproval = pq.premp_num
WHERE n.CreateDate BETWEEN '''[/color] + CONVERT(VARCHAR(12), @StartDate, 101) + [COLOR=red]''' AND '''[/color] + CONVERT(VARCHAR(12), @EndDate, 101) + [COLOR=red]''''[/color]);
[COLOR=blue]IF[/color] @CauseId <> 0
[COLOR=blue]BEGIN
SET[/color] @Sql = (@Sql + [COLOR=red]' AND n.Cause = '[/color] + CAST(@CauseId [COLOR=blue]AS VARCHAR[/color](5)));
[COLOR=blue]END
IF[/color] @IssueDept <> 0
[COLOR=blue]BEGIN
SET[/color] @Sql = (@Sql + [COLOR=red]' AND n.IssuingDept = '[/color] + CAST(@IssueDept [COLOR=blue]AS VARCHAR[/color](5)));
[COLOR=blue]END
IF[/color] @ActionDept <> 0
[COLOR=blue]BEGIN
SET[/color] @Sql = (@Sql + [COLOR=red]' AND n.ActionDept = '[/color] + CAST(@ActionDept [COLOR=blue]AS VARCHAR[/color](5)));
[COLOR=blue]END
EXEC[/color] (@Sql);
[COLOR=blue]END TRY
BEGIN CATCH
INSERT INTO[/color] ErrLog (Number, Severity, ErrState,
ErrSource, ErrLine, ErrMsg, Form, AppID)
[COLOR=blue]SELECT[/color] ISNULL(ERROR_NUMBER(),-1), ISNULL(ERROR_SEVERITY(),0), ISNULL(ERROR_STATE(),0),
ISNULL(ERROR_PROCEDURE(),[COLOR=red]'Unknown.'[/color]), ISNULL(ERROR_LINE(),0),
ISNULL(ERROR_MESSAGE(),[COLOR=red]'Unknown: Failed to Execute SELECT.'[/color]), @ProcName, 3;
[COLOR=blue]END CATCH[/color]
--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------