存储过程,查询时候出的问题

durkingzhang 2008-08-27 05:43:59
create procduce a
@intPageSize int

as

begin


select top rtrim(convert(char,@intPageSize,10))
SN from Product

end


请问这句有什么问题?
...全文
51 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
regithanhu 2008-08-27
  • 打赏
  • 举报
回复
你这是个变量需要用动态sql
alter procduce a 
@intPageSize int
as
begin
declare @s varchar(8000)
set @s='select top +rtrim(convert(char,+'@intPageSize'+,10))
SN from Product '
exec (@sql)

end
lgxyz 2008-08-27
  • 打赏
  • 举报
回复
create procedure a 
@intPageSize int
as
begin
declare @sql varchar(8000)
set @sql='select top '+convert(varchar,@intPageSize)+' * from ta'
exec (@sql)
end
lgxyz 2008-08-27
  • 打赏
  • 举报
回复
[Quote=引用楼主 durkingzhang 的帖子:]
create procduce a
@intPageSize int

as

begin


select top rtrim(convert(char,@intPageSize,10))
SN from Product

end


请问这句有什么问题?
[/Quote]


10是什么意思?
中国风 2008-08-27
  • 打赏
  • 举报
回复
select top (@intPageSize) SN from Product --05以上版本

2000用動態
declare @i int
set @i=10
exec('select top '+@i+' ID from sysobjects')
lgxyz 2008-08-27
  • 打赏
  • 举报
回复
1:
rtrim(convert(char,@intPageSize,10))
这个括号错了吧
2:
应该用动态语句来

fcuandy 2008-08-27
  • 打赏
  • 举报
回复
sql2k只支持top后接常量

34,592

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧