我正在传递两个参数,即@AccountId和@key.我想显示数据库中存在的所有值@AccountId以及@key参数中没有值的时候ie @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
Run Code Online (Sandbox Code Playgroud)