DECLARE @tempTbl TABLE(OrderNo VARCHAR(50))
DECLARE @orderNos VARCHAR(4000)
SET @orderNos='''3f1a82c591fe6e9e'',''a41a501bcb16d0cc1'''; //必须每个订单编号两边有两个单引号,表示转义的单引号
INSERT INTO @tempTbl
EXECUTE
(
'
SELECT OrderNo FROM dbo.tblOrder
WHERE OrderNo IN ('+@orderNos+')'
)
SELECT * FROM @tempTbl;