About Excute () method, used in conjunction with the parameters in

DECLARE @tempTbl TABLE(OrderNo VARCHAR(50))

DECLARE @orderNos VARCHAR(4000)

SET @orderNos = '' '3f1a82c591fe6e9e' ',' 'a41a501bcb16d0cc1' ''; // order number must be on both sides of each two single quotes, represent escaped single quotes

 

INSERT INTO @tempTbl

EXECUTE

(

'

SELECT OrderNo FROM dbo.tblOrder

WHERE OrderNo IN ('+@orderNos+')'

)

 

SELECT * FROM @tempTbl;

 

Guess you like

Origin www.cnblogs.com/zhoushiya/p/12107357.html