定义的存储过程如下:
CREATE PROCEDURE ch 
@chcount0 int OUTPUT
as
  select @chcount0=(select count(distinct 车号) from dbo.运输趟次临时表 )chch即指定的此存储过程

解决方案 »

  1.   

    --存储过程没问题,改了一下表测试CREATE PROCEDURE ch 
    @chcount0 int OUTPUT
    as
      select @chcount0=(select count(distinct id) from dbo.sysobjects )
    godeclare @chcount0 int 
    exec ch @chcount0 out
    select @chcount0
    godrop proc ch
      

  2.   

    我用delphi语言,调用如下:
    str0:=' declare ch scroll cursor for select distinct(车号) from dbo.运输趟次临时表 open ch';
          query1.Close;
          query1.SQL.Clear;
          query1.SQL.Add(str0);
          query1.ExecSQL;
          chch.Prepare;   //chch:从ch取车号个数
          chch.ExecProc;
    请大家再帮忙检查一下吧!!!我实在是不行了!!!
      

  3.   

    执行时:declare @chcount0 int
    exec ch @chcount0=@chcount0 output
    ---print @chcount0
    go
      

  4.   

    你的程序是用游标直接处理,根本没有定义存储过程.delphi不会,所以不知道该如何写
      

  5.   

    查一下delphi是如何调用带返回参数的存储过程的;
    如:(我不会delphi)
    delphi如何调用sql存储过程,并获取结果
    adostoredproc1.close;
    adostoredproc1.procedurename:=sp_thchl;
    adostoredproc1.parameters.clear;
    adostoredproc1.parameters.createparameter(out,ftinteger,pdoutput,1,1);
    adostoredproc1.execproc;
    edit1.text :=adostoredproc1.parameters[0].valu
      

  6.   

    拷错了,是这样的:
    str0:=' declare sj scroll cursor for select distinct(车号) from dbo.运输趟次临时表 open sj';
          query1.Close;
          query1.SQL.Clear;
          query1.SQL.Add(str0);
          query1.ExecSQL;
          chch.Prepare;   //chch:从数
          chch.ExecProc;
      

  7.   

    --存储过程这样定义:
    CREATE PROCEDURE ch as
      select count(distinct 车号) from dbo.运输趟次临时表 
      
    go
    --调用时:
          str0:='exec ch';
          query1.Close;
          query1.SQL.Clear;
          query1.SQL.Add(str0);
          query1.open;
          Fields.Fields[0].Value//chch:从ch取车号个数