0

具有以下脚本用于 StoredProcedure..

CREATE PROCEDURE [dbo].[GetInvestorForExtractReport]
    -- Add the parameters for the stored procedure here
    @rptPrm_AccountNumber varchar(8000),
    @SettlmentDate as datetime
with encryption
AS

    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT distinct
        I.InvestorID, 
        I.InvestorName As [Nombre Inversionista],
        substring(IA.AccountNumber,1,3) accountnumber,
        isnull(AGSL.CashGuarantee,0) As [Garantia Efectivo],
        I.DocumentType As [Tipo Documento],
        I.DocumentNumber As [Numero Documento],
        substring(I.MainAccount,1,3) As [Cuenta CRCC],
        I.InternalInvestorNumber As [Cuenta Interna],
        SUBSTRING(CONVERT(VARCHAR,getdate(),120),1,10) As [Fecha],
        isnull(AGSL.InvestorCashGuarantee,0) As [Efectivo]
    FROM 
        Investors I
        INNER JOIN investoraccounts IA 
            ON (I.InvestorId = IA.InvestorId AND IA.AccountNumber like '%01' AND
            (substring(IA.AccountNumber,1,3) IN (select param from  dbo.fn_ReportParams(@rptPrm_AccountNumber,','))))
        LEFT JOIN AccountGuaranteeStatusLog AGSL
            ON (AGSL.InvestorAccount = substring(IA.AccountNumber,1,3)
                AND datediff(dd,AGSL.SettlmentDate ,@SettlmentDate)=0)
    order by substring(IA.AccountNumber,1,3)
GO

如果删除SET NOCOUNT ON,并且使用相同的参数执行存储过程,则列的值会[Efectivo]发生变化!这怎么可能?

4

2 回答 2

0

如果您尝试在 SSMS 中运行存储过程,无论 NOCOUNT 是 ON 还是 OFF,数据结果都应该相同。如果您发现结果确实不同,那么这可能是您采取行动的时机巧合。

不同之处在于你会从你的存储过程中得到类似的东西:(494行受影响)

当从程序执行此操作时,通常您会返回第二个数据集,并带有此值。

于 2013-07-18T13:48:28.540 回答
0

我不知道你是否解决了这个问题,但是如果你像下面这样修改你的 sp,你能告诉我你是否仍然遇到同样的问题吗?

CREATE PROCEDURE [dbo].[GetInvestorForExtractReport]
-- Add the parameters for the stored procedure here
@rptPrm_AccountNumber varchar(8000),
@SettlmentDate as datetime

带加密 AS

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT distinct
    I.InvestorID, 
    I.InvestorName As [Nombre Inversionista],
    substring(IA.AccountNumber,1,3) accountnumber,
    isnull(AGSL.CashGuarantee,0) As [Garantia Efectivo],
    I.DocumentType As [Tipo Documento],
    I.DocumentNumber As [Numero Documento],
    substring(I.MainAccount,1,3) As [Cuenta CRCC],
    I.InternalInvestorNumber As [Cuenta Interna],
    SUBSTRING(CONVERT(VARCHAR,getdate(),120),1,10) As [Fecha],
    isnull(AGSL.InvestorCashGuarantee,0) As [Efectivo]
FROM 
    Investors I
    INNER JOIN investoraccounts IA 
        ON (I.InvestorId = IA.InvestorId AND IA.AccountNumber like '%01' AND
        (substring(IA.AccountNumber,1,3) IN (select param from  dbo.fn_ReportParams(@rptPrm_AccountNumber,','))))
    LEFT JOIN AccountGuaranteeStatusLog AGSL
        ON (AGSL.InvestorAccount = substring(IA.AccountNumber,1,3))
            where datediff(dd,AGSL.SettlmentDate ,@SettlmentDate)=0
order by substring(IA.AccountNumber,1,3)
于 2013-07-26T08:08:04.630 回答