我希望能够在我的SSRS报告中添加另一个参数,该参数将使用我的SQL存储过程中的CustNum进行搜索。当我将@custnum INT参数添加到SQL存储过程中时,它不会通过&返回任何结果。我收到了这个错误消息:::
消息102,级别15,状态1,程序GPA,行254 [批处理开始行9]语法不正确'结束'
知道如何添加此参数以便我可以通过客户编号以及过期日期来提取信息。
这里 - 数据集1(来自存储过程):
USE [database]
GO
/****** Object: StoredProcedure [dbo].[GPA] Script Date: 6/23/2017 4:22:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GPA]
(
@DaysPD INT,
@CustNum INT
)
AS
BEGIN
SET NOCOUNT ON;
-- exec GPA 45
SELECT DISTINCT inv.InvoiceId AS InvoiceID
,ent.EnterpriseName AS Enterprise
,inv.customerNumber AS CustNum
,cust.CompanyName AS CustName
,inv.InvoiceNum AS InvNum
,inv.TotalAmountDue AS Amount
,inv.DocDate AS DocDate
,inv.DueDate AS DueDate
,datediff(day, GETDATE(), inv.DueDate) * - 1 AS DaysPastDue
,CASE
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 1
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 1
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 1
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 2
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 2
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 2
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 3
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 3
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 3
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 4
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 4
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 4
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 5
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 5
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 5
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 6
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 6
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 6
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 7
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 7
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 7
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 8
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 8
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 8
)
WHEN (
SELECT datediff(day, inv.DueDate, GETDATE())
) >= (
SELECT [from]
FROM cs_agingbucket
WHERE agingdetailid = 9
AND [from] <> 0
)
AND (
SELECT datediff(day, inv.DueDate, GETDATE())
) <= (
SELECT [to]
FROM cs_agingbucket
WHERE agingdetailid = 9
--AND [to] <> 0
)
THEN (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 9
)
ELSE (
SELECT label
FROM CS_AgingBucket
WHERE AgingDetailId = 10
)
END Aging
,stat.NAME [Status]
,invact.lastactname AS LastAct
,invact.WorkDate AS LastActDate
,invact.nextactname AS NextAct
,invact.NextWorkDate AS NextActDate
,us.FirstName + ' ' + us.LastName AS UserID
,isnull(cur.Symbol, '$') AS CurSymbol
FROM CS_Invoice inv
JOIN CS_Customer cust ON cust.CustomerId = inv.CustomerId
JOIN CS_Enterprise ent ON inv.EnterpriseId = ent.EnterpriseId
LEFT JOIN CS_Account acct ON cust.CustomerId = acct.CustomerId
JOIN CS_User us ON acct.UserId = us.UserId
JOIN CS_Status stat ON stat.StatusId = inv.InvstatusId
LEFT JOIN (
SELECT maxwork.invoiceid
,WORK.ActionTakenId
,lastact.NAME lastactname
,WORK.NextActionId
,nextact.NAME nextactname
,WORK.WorkDate
,WORK.NextWorkDate
FROM CS_WorkAccount WORK
LEFT JOIN CS_SecurityPrivilege lastact ON WORK.ActionTakenId = lastact.SecurityPrivilegeId
LEFT JOIN CS_SecurityPrivilege nextact ON WORK.NextActionId = nextact.SecurityPrivilegeId
JOIN (
SELECT workinv.InvoiceId
,max(workinv.workaccountid) maxid
FROM CS_WorkAccountInvoice workinv
GROUP BY workinv.InvoiceId
) maxwork ON WORK.WorkAccountId = maxwork.maxid
) invact ON inv.invoiceid = invact.invoiceid
LEFT JOIN CS_Currency cur ON cur.CurrencyId = inv.CurrencyId
WHERE inv.TotalAmountDue <> 0
AND datediff(day, GETDATE(), inv.DueDate) * - 1 >= @DaysPD
IF ((@CustNum != 0 AND @CustNum = @CustNum)
END
GO
&#13;
知道如何让@CustNum参数在SSRS中工作。