| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 508 人关注过本帖
标题:提出最新几条信息用存储过程,加top为什么不行??
只看楼主 加入收藏
yzwt2004
Rank: 1
等 级:新手上路
帖 子:472
专家分:0
注 册:2006-1-18
收藏
 问题点数:0 回复次数:0 
提出最新几条信息用存储过程,加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

这样就能运行通过得到结果,晕那里错了,

搜索更多相关主题的帖子: top 
2007-04-17 17:49
快速回复:提出最新几条信息用存储过程,加top为什么不行??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045683 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved