如何书写这句存储过程?aspnetpager中的.

zjhzzc001 2005-03-24 08:47:27
ALTER procedure GsjyShowDGProcessor
(@where varchar(100),
@pagesize int,
@pageindex int,
@docount bit)
as
set nocount on
declare @RecordCount int
select @RecordCount=count (id) from news
if(@docount=1)
select @RecordCount
else
begin
if(@pageindex=1)
exec('select top '+@pagesize+'* from news'+@where+' order by indextime desc')
else
begin
declare @PageUpperBound int
declare @endrecords int
set @PageUpperBound=@pageindex*@pagesize
if(@PageUpperBound-@pagesize)>=@RecordCount
select ''
else if(@RecordCount-(@PageUpperBound-@pagesize)<=@pagesize)
begin
set @endrecords=@RecordCount-(@PageUpperBound-@pagesize)
exec('select * from (select top '+@endrecords+' * from news'+@where+' order by indextime)A order by indextime desc')
end
else
exec('select * from (select top '+@pagesize+'* from (select top '+@PageUpperBound+' * from news'+@where+' order by indextime desc)A order by indextime)B order by indextime desc')
end
end
set nocount off


我的@where参数是如"where a='1'and b='2' and c='3' ....."程序中生成的动态语句.
如何改写select @RecordCount=count (id) from news
使RecordCount 的值是条件中的记录总数,而不是所有的记录数.
这个@where参数该如何添上?
谢谢.
...全文
116 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bigcarp 2005-03-26
  • 打赏
  • 举报
回复
不一定要存储过程啊,你在程序中实现就可以啦
zjhzzc001 2005-03-25
  • 打赏
  • 举报
回复
to:hackate(~兰心*-*寒~ | 个人网站: http://www.7to.net)
利用where语句,想控制count的统计范围,而不是count的字段.
zjhzzc001 2005-03-25
  • 打赏
  • 举报
回复
怎么没有人回复了,等...................
hackate 2005-03-24
  • 打赏
  • 举报
回复
select @RecordCount=count (@xx) from news

@xx就可以只选择的字段嘛
jerryf 2005-03-24
  • 打赏
  • 举报
回复
学习

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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