提出最新几条信息用存储过程,加top为什么不行??
create proc info
@topsl int
as
declare @s varchar(5000)
begin
set @s='SELECT top '+@topsl+' * from users order by id desc'
exec (@s)
end
go
前台调用:
set rs = server.createobject("adodb.recordset")
rs.Open " exec info 5",conn,1,1
以上代码无法运行,
但是下面这种情况就能通行:
create proc info
as
declare @s varchar(5000)
begin
set @s='SELECT top 7 * from users order by id desc'
exec (@s)
end
go
前台调用:
set rs = server.createobject("adodb.recordset")
rs.Open " exec info ",conn,1,1
这样就能运行通过得到结果,晕那里错了,