0

When I execute the below SQL statement, I get an error

Must declare the scalar variable "@AuditKey"

I feel like this is so simple and I am making a really dumb mistake. Thanks in advance!

ALTER PROCEDURE [ProjectSpecific].[spTarget]
    -- Parameter 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
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
JShep
  • 11
  • 2

1 Answers1

0

Should be:

DECLARE @Key varchar(100)
TrevorBrooks
  • 3,590
  • 3
  • 31
  • 53