我无法让这个工作。 ARR!如果@DiscountName是某个值,我正在尝试添加额外的AND。我正试图在输入参数@DiscountName =“MyValue”
的情况下使用额外的AND语句ALTER PROCEDURE [dbo].[usp_Discount_InsertDiscountBatch]
@CustomerNumber Int,
@DiscountName Varchar(50),
...
AS
Select @currDate, [dbo].[TransactionActivity].Id
From [dbo].[TransactionActivity]
Where
[dbo].[TransactionActivity].CustomerNumber = @CustomerNumber
And
Case When @DiscountName = 'Member' Then
[dbo].[TransactionActivity].IsMember
Else ''
End
这适用于MS SQL服务器。
答案 0 :(得分:2)
目前还不清楚你想要什么。也许是这样的事情:
Where [dbo].[TransactionActivity].CustomerNumber = @CustomerNumber AND
(@DiscountName <> 'Member' or [dbo].[TransactionActivity].IsMember = 1)
答案 1 :(得分:0)
我在这里找到了解决方案:http://weblogs.sqlteam.com/jeffs/archive/2003/11/14/513.aspx
WHERE @Filter<>1 OR (Date= @Date and Cust= @Cust and Emp= @Emp
)