Sql and Where Clause with Data Type Table

Hi, i have a data type table which i pass from C# with list of int.
i use it in the query :
select * from tbl1 where statudid in (select id from datatypetable)
the questio if the data type table which i pass is empy,
how can i get all value as doing some like

select...
where
statusid=case when "datatypetable is empty" then statusid else (select id from datatypetable) end

thanks

where (not exists(select 1 from dbo.datatypetable) or statusid in (select id from datatypetable))

1 Like