我從SSRS報表的數據集中複製了一個查詢,例如3個參數。在實際情況中,我有許多約30個參數。我想在SSMS中測試這個查詢,並用我自己的值處理參數。但我想要填充查詢一個參數 - @ par1,其他必須具有所有值。如何忽略查詢中的參數而不進行查詢查詢
drop table testtable;
create table testtable(param1 int,param2 int,param3 int)
insert into testtable values
(1,10,20),(2,11,21),(3,12,22);
--added parametrs to help query work
declare @par1 int;
declare @par2 int;
declare @par3 int;
set @par1=1;
set @par2= ? --what i need to put here to have only @par1 condition implemented in query
set @par3= ? --what i need to put here to have only @par1 condition implemented in query
-- Dataset Copyed from SSRS Report. And I dont want to delete anything from here, because query is complex in real situation.
select *
from testtable
where
[email protected] and [email protected] and [email protected]
你想忽略的參數時,它是'NULL' –
如果參數爲null。我不想忽視它。在這種情況下將是Where @par = null –
我不認爲你可以做你正在尋找的東西。我認爲最好的選擇是修改查詢。此外,如果你能做到這一點,而且你對查詢沒有很好的理解,那麼你可能會引入一個錯誤。 – Dane