请交gahade(与君共勉)一个问题
declare @cc int
set @cc=3
SELECT TOP 1 istr FROM uf_splitstring( 'aa,bb,cc,dd,ee,ff,gg,hh,kk ', ', ')
WHERE (ID NOT IN
(SELECT TOP @cc id FROM uf_splitstring( 'aa,bb,cc,dd,ee,ff,gg,hh,kk ', ', ')
ORDER BY id))
ORDER BY id
提示错误: '@cc ' 附近有语法错误。
请问错在那里?^_^
------解决方案--------------------declare @cc int
set @cc=3
declare @sql varchar(1000)
select @sql= '
SELECT TOP 1 istr FROM uf_splitstring( ' 'aa,bb,cc,dd,ee,ff,gg,hh,kk ' ', ' ', ' ')
WHERE (ID NOT IN
(SELECT TOP '+rtrim(@cc)+ ' id FROM uf_splitstring( ' 'aa,bb,cc,dd,ee,ff,gg,hh,kk ' ', ' ', ' ')
ORDER BY id))
ORDER BY id '
exec(@sql)