我正在传递两个参数,即@AccountId
和@key
。我想显示数据库中存在的所有值,@AccountId
以及@key
当参数中没有值时,即@AccountId
和@key
。我想对同一个数据集执行此操作。这是可能的还是我创建了不同的数据集?
我正在使用的查询是:
CREATE PROCEDURE [dbo].[GetDenyList]
@AccountId nvarchar(100),
@key nvarchar(400)
AS
select New_AccountId AS 'AccountId/Key', New_Description AS 'Reason',CreatedOn AS 'Date'
from abc.dbo.New_keydenylist
where New_AccountId is not null
AND @AccountId = New_AccountId
union all
select new_key AS 'AccountId/Key', New_Description AS 'Reason',CreatedOn AS 'Date'
from abc.dbo.New_keydenylist
where New_key is not null
and @Key=New_key