当前位置: 代码迷 >> Sql Server >> ms-sql top where和 变量的有关问题
  详细解决方案

ms-sql top where和 变量的有关问题

热度:127   发布时间:2016-04-27 14:58:27.0
ms-sql top where和 变量的问题
declare @num int
set @num=9
exec('select top ' + @num + ' * from 职工 where 仓库号 in(wh1,wh4)')



select top 9 * from 职工 where 仓库号 in('wh1','wh2')

怎么实现啊,上面使用动态SQL出现错误! 拜求~

------解决方案--------------------
2000用动态sql,2005+加个括号就行,
  相关解决方案