存储过程问题

a97191 2006-06-01 03:07:10
我要同时返回参数和记录和记录集,请问怎么做,我用下面总是做不好
存储过程,自己测试过,存储过程是没有问题的
create procedure mainboard_graphTypeno
@second int output,
@yyear int,
@mmonth int
as
begin
select @second=count(*) from (select *from mainboard where year(fix_date)=@yyear and month(fix_date)=@mmonth) a
inner join (select typename from mainboard where year(fix_date)<=@yyear and month(fix_date)<=@mmonth
group by typename having count(typename)>=2) b on a.typename=b.typename

select typeno,dd=(select count(1) from mainboard where typeno=a.typeno and year(fix_date)=@yyear and month(fix_date)=@mmonth and type='主板') from mainboard a where year(fix_date)=@yyear and month(fix_date)=@mmonth and type='主板' group by typeno
order by dd desc

asp文件
set cmd=server.CreateObject("adodb.command")
cmd.ActiveConnection=conn
cmd.CommandText="dbo.mainboard_graphTypeno"
cmd.CommandType=4
cmd.Prepared=true
cmd.Parameters.Append cmd.CreateParameter("@second",2,3)
cmd.Parameters.append cmd.CreateParameter("@yyear",3,1,4,yyear)
cmd.Parameters.append cmd.CreateParameter("@mmonth",3,1,4,mmonth)
'set rs=server.CreateObject("adodb.recordset")
'rs.Open cmd,,1,1
set rs=cmd.execute
rowcount=cmd.Parameters("@second").value
do while not rs.eof
....
rs.MoveNext
loop
...全文
110 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaoyaomaomao 2006-06-01
  • 打赏
  • 举报
回复
create procedure mainboard_graphTypeno
@second int output,
@yyear int,
@mmonth int
as
select typeno,dd=(select count(1) from mainboard where typeno=a.typeno and year(fix_date)=@yyear and month(fix_date)=@mmonth and type='主板') from mainboard a where year(fix_date)=@yyear and month(fix_date)=@mmonth and type='主板' group by typeno
order by dd desc

select @second=count(*) from (select *from mainboard where year(fix_date)=@yyear and month(fix_date)=@mmonth) a
inner join (select typename from mainboard where year(fix_date)<=@yyear and month(fix_date)<=@mmonth
group by typename having count(typename)>=2) b on a.typename=b.typename

这么写试试,因为有的应用程序如DELPHI只接受第一个SELECT 返回的结果集
yaoyaomaomao 2006-06-01
  • 打赏
  • 举报
回复
另外需要的结果集需要用select重新查询
yaoyaomaomao 2006-06-01
  • 打赏
  • 举报
回复
create procedure mainboard_graphTypeno
@second int output,
@yyear int,
@mmonth int
as
SET NOCOUNT ON (加上这个试试)
a97191 2006-06-01
  • 打赏
  • 举报
回复
可以我已经试过,如果把这句
select @second=count(*) from (select *from mainboard where year(fix_date)=@yyear and month(fix_date)=@mmonth) a
inner join (select typename from mainboard where year(fix_date)<=@yyear and month(fix_date)<=@mmonth
group by typename having count(typename)>=2) b on a.typename=b.typename
去掉,是可以返回记录集的,但我要返回一个值,不知有没有这方面的列子,同时返回参数和记录集
yaoyaomaomao 2006-06-01
  • 打赏
  • 举报
回复
cmd.execute好象是不返回结果集的
yaoyaomaomao 2006-06-01
  • 打赏
  • 举报
回复
结果集的返回可以在程序里面设置的啊,不用cmd.execute,ASP里面有没有open?
慧龙照片恢复软件是一个特殊的数据恢复工具,专门用于恢复误删除、格式化、文件系统错误、分区打不开等造成的照片文件丢失;支持硬盘、光盘、U盘、MP3、数码相机、手机、存储卡等存储介质。支持FAT、FAT32、NTFS、CDFS等各种分区格式,但不能恢复在NTFS分区中压缩存储的文件,也不能恢复加密的文件。全盘扫描查找照片数据,不放过任何一个可恢复的照片文件。   慧龙照片恢复软件在恢复文件过程中不会往源分区写入数据,因此可保证不会对源数据造成再次损害,可放心使用。软件还支持从磁盘映像文件中恢复照片文件,方便进行异地数据恢复,软件本身也具有制作磁盘映像文件的功能。   本软件目前仅支持恢复JPG格式的照片文件(更多文件格式正在增加中),JPG格式是最流行的数码照片文件格式,绝大多数数码相机及拍照手机均采用该格式存储照片,因此慧龙照片恢复软件能胜任绝大多数照片文件的恢复任务,照片恢复的成功率也很高。   慧龙照片恢复软件会提取照片文件中的拍照时间,作为恢复出来的文件修改时间,方便恢复后对照片进行整理。只要在文件夹里选择按“修改时间”排序,照片就是按拍照的先后顺序排列了,非常方便。   提示: 不要下载软件到要恢复数据的盘符里,也不要解压文件到要恢复的盘符里,否则可能再次破坏源数据。如果是相机直接连接电脑进行数据恢复,请保证电池电量足够,免得恢复过程中耗完电了,下次又要重新扫描。   为什么选择慧龙照片恢复软件?与其他数据恢复软件相比,慧龙照片恢复软件具有以下特点:   1. 逐一扫描存储扇区,寻找照片数据,提高照片文件恢复成功率;   2. 使用超简单,鼠标点击几下即可开始恢复;   3. 体积小,下载快,绿色软件,无需安装,不会在系统里留下任何垃圾;   4. 不依赖于文件系统,即使目录区、文件分配表完全损毁也能进行恢复;   5. 支持从映像文件恢复照片,因而可完全避免反复扫描对源数据造成损害;软件本身也包含制作映像文件的功能。

34,838

社区成员

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

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