[当我执行下面的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
应该是:
DECLARE @Key varchar(100)