我有一个存储过程,它使用一个名为@Command (nvarchar(MAX))
. 然后我根据给定的输入相应地添加参数。
declare @Command nvarchar(max)
if(@CaseFileID IS NOT NULL)
BEGIN
select @Command='
select [ServerCredentialsID],[CaseFileID],EIKSLT.[LocationType],EPT.PaymentType,[TaskID],[DateActive]
,[LengthOfPurchase],[Username],[Password],[IPDomain],[Port],[DES],[Website],[AmountPaid],[Latitude]
,[Longitude],[HasAttachments],[TimeStamp],[CaseElement],[Temporary],[StatusID]
FROM Element17a_IKSServerCredentials EIKSSC
JOIN ElementsIKSLocationTypes EIKSLT ON EIKSSC.LocationBeingUsedID= EIKSLT.IKSLocationBeingUsedID
JOIN ElementsPaymentTypes EPT ON EIKSSC.PaymentMethodID=EPT.PaymentTypeID
where EIKSSC.CaseFileID='''+cast(@CaseFileID as nvarchar(MAX))+''' '
@CaseFileID 被声明为一个 int,在表中它是一个 int。当我尝试
where EIKSSC.CaseFileID = ' + @CaseFileID + ' '
然后该值甚至不显示(在错误中看起来像"EIKSSC.CaseFileID= '"
)
我只是不明白。
注意:SQL Server 2008 管理工作室