在SQL中声明标量变量错误-SSMS

问题描述 投票:0回答:1

[当我执行下面的SQL时,出现错误“必须声明标量变量” @AuditKey“,我觉得这很简单,我犯了一个非常愚蠢的错误。在此先感谢!

--Paramater is AuditKey
            @Key varchar(100)

AS
BEGIN
SET @Key = 'Key'
SET NOCOUNT ON;


CREATE TABLE #Audit
        (   
              AccountID         int
            , Acct              varchar(50)
            , RevCode           smallint
            , HCPCS             varchar(5)
        )

INSERT INTO #Audit

SELECT    II.AccountID
        , II.Acct
        , IB.RevCode
        , IB.HCPCS


FROM Trakker.InsuranceInfo II
    Inner Join Trakker.ItemizedBill IB
            ON II.AccountID = IB.AccountID

WHERE Rate.Key = @Key

END
sql ssms ssms-2017
1个回答
0
投票

应该是:

DECLARE @Key varchar(100)

© www.soinside.com 2019 - 2024. All rights reserved.