create procedure S_test
@id   int
@Total varchar(50)
as
 @total = select * from test where id=@idgo我想把查出来的记录,返回到一个变量怎么实现啊 .
(注:在用这个变量完成一下功能,如table(id),取值)

解决方案 »

  1.   

    上面的(注:在用这个变量完成一下功能,如table(id),取值)的table改为:total,刚才发错了。
      

  2.   

    就是
    把用这个语句(select * from test where id=@id)查出来的记录存到一个变量中
      

  3.   

    就是那个@total定义成数组变量。
      

  4.   

    create procedure S_test
    @id   int
    @Total varchar(50) output
    as
     @total = select * from test where id=@idgo由于不清楚你究竟想在表中查出什么东西,所以sql语句按你原来的写出。
    只给出要把@Total 作为返回参数返回的方法。代码中:
    SqlCommand cmd = SqlCommand("S_test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    myParm = cmd.Parameters.Add("@Total", SqlDbType.varchar);
    myParm.Direction = ParameterDirection.Output;
      

  5.   

    实现的功能是类似下面的功能:if moveWay="down" then
      set tmp=sqlQuery(getSQL("select * from {viewTabClass} where {viewClsID}="&classId&" and  {viewClsOwnerID}="&spy.getValue("userId")))
      if tmp(viewClsNextID)=0 then
       call throwException(1,"已到达边界")
      end if
      

  6.   

    create procedure S_test
    @id   int,
    @Total varchar(50) output
    as
     @total = select * from test where id=@idgo
    出错了!
    服务器: 消息 170,级别 15,状态 1,过程 S_test,行 5
    第 5 行: '@total' 附近有语法错误。
      

  7.   

    我想实现的是:返回的记录集能想以上的"tmp",能把查出来的字段“id”的值,能用“total(id)“的形式调用。