开发者

How can stored procedure return no rows when called from BIDS but return rows when called from SSMS when using the same parameter?

开发者 https://www.devze.com 2023-04-04 20:02 出处:网络
Using SSRS 2008R2 with a SQL Server 2005 database for the Data Source. I have a report (.rdl file) built in Business Intelligence Development Studio (VS 2008). It uses a stored procedure as the sourc

Using SSRS 2008R2 with a SQL Server 2005 database for the Data Source.

I have a report (.rdl file) built in Business Intelligence Development Studio (VS 2008). It uses a stored procedure as the source of the data. The proc takes one parameter, an INT which is a unique key for the main table in the one SELECT in the proc.

For some parameter values, executing the proc from within the Query Designer of BIDS returns no rows. Executing the same procedure from SSMS using the same parameter value does return rows. Profiler shows the same SELECT regardless of whether the call is made from BIDS or SSMS. How could they get different results?

Here is the proc:

CREATE PROCEDURE [Report_BatchEdit开发者_JAVA百科]
    @BatchAltId INT
AS
   SELECT   b.[BatchAltId]
            , fs.[Name] AS [FundingSource]
            , b.[StartDate] AS [StartDate]
            , b.[StopDate] AS [StopDate]
            , b.[Description]
            , b.[Created]
            , bl.[BillId]
            , COALESCE(c.[Name], bill.RecipientCustomerName) AS [CustomerName]
            , COALESCE(ri.[Identifier], bill.[RecipientIdentifier]) AS [MedicaidNumber]
            , bill.[NetTotal] AS [ClaimAmount]
            , bl.[BillingCodeCode] AS [BillingCode]
            , bl.[BillingCodeDescription] AS [BillingCodeDescription]
            , bl.[StartDate] AS [FromDate]
            , bl.[StopDate] AS [ToDate]
            , bl.[UnitSizeName] AS [UnitSize]
            , bl.[CalculatedUnits] AS [Units]
            , bl.[Rate]
            , bl.[Amount]
            , fs.UsesModifiers
            , CASE WHEN fs.UsesModifiers = 1 THEN rm1.[Code] ELSE NULL END AS [RateModifier1Code]
            , CASE WHEN fs.UsesModifiers = 1 THEN rm2.[Code] ELSE NULL END AS [RateModifier2Code]
            , CASE WHEN fs.UsesModifiers = 1 THEN rm3.[Code] ELSE NULL END AS [RateModifier3Code]
            , CASE WHEN fs.UsesModifiers = 1 THEN rm4.[Code] ELSE NULL END AS [RateModifier4Code]
    FROM    [Batch] AS b 
            JOIN [Bill] AS bill ON b.[BatchId] = bill.[BatchId] 
            JOIN [BillLine] AS bl ON bill.[BillId] = bl.[BillId]
            JOIN [Customer] AS fs ON b.[PayerCustomerId] = fs.[CustomerId]
            LEFT JOIN [Customer] AS c ON bill.[RecipientCustomerId] = c.[CustomerId]
            LEFT JOIN [RecipientIdentifier] AS ri ON b.[PayerCustomerId] = ri.[PayerCustomerId] AND bill.[RecipientCustomerId] = ri.[RecipientCustomerId]
            LEFT JOIN [RateModifier] AS rm1 ON bl.[RateModifier1Id] = rm1.[RateModifierId]
            LEFT JOIN [RateModifier] AS rm2 ON bl.[RateModifier2Id] = rm1.[RateModifierId]
            LEFT JOIN [RateModifier] AS rm3 ON bl.[RateModifier3Id] = rm1.[RateModifierId]
            LEFT JOIN [RateModifier] AS rm4 ON bl.[RateModifier4Id] = rm1.[RateModifierId]
   WHERE    BatchAltId = @BatchAltId 
ORDER BY    [FundingSource], b.[StartDate], b.[Description], [CustomerName], [BillingCode], [FromDate], [ToDate]


It sounds silly thing but are you sure the BIDS package is referencing the database on the same server as where SSMS query is running? When I've had things like this happen, I've almost always found an error in the cofiguration of the package and the datasource was pointing to the wrong server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号