日期:2014-05-18  浏览次数:20449 次

关于嵌套变量的求教!
declare @kc money,@sql varchar(8000)
set @kc=50
......
set @sql='select b.clsname,a.* from ('+@sql+') as a,clsitem b where countn<=变量KC and a.clscode=b.clscode'


代码该如何写啊?是countn<='''+@kc+'''还是什么呢?


------解决方案--------------------
SQL code

countn<=''''+ltrim(@kc)+''''

------解决方案--------------------
SQL code
set @sql='select b.clsname,a.* from ('+@sql+') as a,clsitem b where countn<= '''+@kc+''' and a.clscode=b.clscode'