if object_id('tb')is not null drop table tb
go
create table tb(ID int identity,[Name] varchar(10))
insert tb select 'A' union all select 'B' union all select 'C'
if object_id('pro_test','P')is not null drop proc pro_test
go
create proc pro_test
@ID int ,
@name varchar(10) output -----------
as 
 select @name=name from tb where id=@id
go
declare @name varchar(10)
exec pro_test 2,@name output
select @name
/*           
---------- 
B*/

解决方案 »

  1.   

    给你一个参考代码:
    CREATE PROC Aa
    AS
    SELECT getdate()
    RETURN 20
    goDim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    conn.ConnectionString = "...."
    conn.OpenSet rs = conn.Execute("declare @a int;exec @a=aa;select @a x")
    Debug.Print rs.NextRecordset.Fields(0).Value'此值即为返回值
      

  2.   

    看ado手册啦,抄抄就有了。create proc p
    as
      retutn 1定义一个adocommand,
    为它定义一个参数,参数类型为返回参数。
    adocommand执行存储过程p后,得到刚才定义的参数的值就是了。
      

  3.   

    本帖最后由 fcuandy 于 2008-12-05 12:25:41 编辑