我正在使用 SSRS 进行报告并执行存储过程来为我的报告生成数据
DECLARE @return_value int
EXEC @return_value = [dbo].[MYREPORT]
@ComparePeriod = 'Daily',
@OverrideCompareDate = NULL,
@PortfolioId = '5,6',
@OverrideStartDate = NULL,
@NewPositionsOnly = NULL,
@SourceID = 13
SELECT 'Return Value' = @return_value
GO
在上面,当我通过时@PortfolioId = '5,6'
,它给了我错误的输入
我需要所有记录,portfolio id 5 and 6 also
这是发送多个值的正确方法吗?
当我执行我的报告时,只给@PortfolioId = '5'
它给我 120 条记录,当我通过给它执行它时@PortfolioId = '6'
给我 70 条记录
所以当我给它的时候@PortfolioId = '5,6'
,它应该只给我 190 条记录,但它给了我更多的记录,我不明白我到底哪里出错了。
有人可以帮我吗?谢谢
所有代码都太大而无法粘贴,我正在粘贴相关代码,请提供线索。
CREATE PROCEDURE [dbo].[GENERATE_REPORT]
(
@ComparePeriod VARCHAR(10),
@OverrideCompareDate DATETIME,
@PortfolioId VARCHAR(50) = '2', --this must be multiple
@OverrideStartDate DATETIME = NULL,
@NewPositionsOnly BIT = 0,
@SourceID INT = NULL
) AS
BEGIN
SELECT
Position.Date,
Position.SecurityId,
Position.Level1Industry,
Position.MoodyFacilityRating,
Position.SPFacilityRating,
Position.CompositeFacilityRating,
Position.SecurityType,
Position.FacilityType,
Position.Position
FROM
Fireball_Reporting.dbo.Reporting_DailyNAV_Pricing POSITION WITH (NOLOCK, READUNCOMMITTED)
LEFT JOIN Fireball.dbo.AdditionalSecurityPrice ClosingPrice WITH (NOLOCK, READUNCOMMITTED) ON
ClosingPrice.SecurityID = Position.PricingSecurityID AND
ClosingPrice.Date = Position.Date AND
ClosingPrice.SecurityPriceSourceID = @SourceID AND
ClosingPrice.PortfolioID IN (
SELECT
PARAM
FROM
Fireball_Reporting.dbo.ParseMultiValuedParameter(@PortfolioId, ',') )