dECLARE @LS_SQL CHAR(100)
dECLARE @SQL varCHAR(max)
SET @LS_SQL=ltrim('''STOCK IN HAND'',''STORE'',''PRODUCT''')
set @SQL='SELECT * FROM ITEM WHERE GROUPNAME IN(' + rtrim(@LS_SQL) + ')'
PRINT @SQL
execute @SQL
结果
SELECT * FROM ITEM WHERE GROUPNAME IN('STOCK IN HAND','STORE','PRODUCT') Msg 2812, Level 16, State 62, Line 9 找不到存储过程 'SELECT * FROM ITEM WHERE GROUPNAME IN('STOCK IN手','商店','产品')'。