SQL server 2005中这句话对的,怎么改成在2000中正常运行啊,现在在2000中要报错,怎以才能在2000中运行出2005同样的效果?请教高手了!
select top(@size) a.idd as typeid,a.tname,a.ordernum,b.idd,b.title,b.pubtime,b.isHot,b.isTop,b.isCommend,b.viewCount,b.lastTime,b.isOutUrl,b.outUrl,imgLink
from newsType_tb as a inner join news_tb as b on a.idd=b.typeid
用一下存储过程。
Code
set nocount on
declare @strSQL NvarChar(2000)
set @strSQL = N'SELECT TOP ' + convert(VarChar(12),@size) + ' a.idd as typeid,a.tname,a.ordernum,b.idd,b.title,b.pubtime,b.isHot,b.isTop,b.isCommend,b.viewCount,b.lastTime,b.isOutUrl,b.outUrl,imgLink
FROM newsType_tb as a inner join news_tb as b on a.idd=b.typeid'
exec sp_executesql @strSQL
存储过程中top后加变量的方法,可以参考这里
http://blog.csdn.net/downmoon/archive/2006/04/12/660557.aspx
或
http://www.cnblogs.com/downmoon/archive/2007/12/29/1019686.html
用脚本导出工具:选择类型为Sql2000,系统会自动转换。