如何在 SQL Server 中声明 int 数组?
填好后,我想在IN语句中使用它来检查,我该如何更改我的代码?
declare @mode int =1
declare @acceptedFormTypeIds table (id int)
case @mode
when 1 then
insert into @acceptedFormTypeIds(id) values (1, 2, 3, 4)
when 2 then
insert into @acceptedFormTypeIds(id) values (1, 3)
when 3 then
insert into @acceptedFormTypeIds(id) values (2, 4)
else
insert into @acceptedFormTypeIds(id) values (1, 2, 3, 4)
end
...
WHERE
tFRM.SendDate between @datefrom and @dateto
and tFRM.TemplateId IN @acceptedFormTypeIds.id