我有一个用户定义的类型如下
CREATE TYPE [dbo].[HaveItemUdt] AS TABLE(
[Defindex] [int] NULL
)
在我的存储过程中
@HaveItemList AS HaveItemUdt READONLY
SELECT * FROM tbl_something WHERE itemID IN (SELECT itemID FROM @HaveItemList)
当@HaveItemList 为空时,我想像这样选择整个表
SELECT * FROM tbl_something WHERE itemID IN (SELECT itemID FROM tbl_something )
我试试这个但不起作用
SELECT * FROM tbl_something WHERE itemID IN (SELECT itemID FROM @HaveItemList) OR @HaveItemList IS NULL
知道怎么做吗?