ALTER PROCEDURE [dbo].[Time_Insert]
    
    @ip varchar(50)  ,
@RETURN_ID int = 0 OUTPUT
as
    
begin
    declare @tmp int 
    insert into WorkTime(UserID,Time)
    select UserID ,getdate() from EmployeeInfo as E where E.ip=@ip
    select @tmp=UserID
    set  @RETURN_ID=@tmp
return @@ERROR
end
    我想得到UserID的值,应该怎么写这个存储过程,谢谢!

解决方案 »

  1.   


    ALTER PROCEDURE [dbo].[Time_Insert] 
        @ip varchar(50)  , 
        @RETURN_ID int = 0 OUTPUT 
    as 
        
    begin 
        declare @tmp int     select @RETURN_ID  = UserID from EmployeeInfo as E where E.ip=@ip     insert into WorkTime(UserID,Time) 
        select @RETURN_ID  ,getdate() 
        return 0
    end declare @id int
    exec Time_Insert 1,@id output
    print @id
      

  2.   

    然后另外一个存储过程想调用这个存储过程的返回值,例如select @tmp from
    应该怎么调用呢?
      

  3.   

    ALTER PROCEDURE [dbo].[Time_Insert] 
        
        @ip varchar(50)  , 
    @RETURN_ID int = 0 OUTPUT 
    as 
        
    begin 
        declare @tmp int 
        insert into WorkTime(UserID,Time) 
        select UserID ,getdate() from EmployeeInfo as E where E.ip=@ip 
        select @RETURN_ID=UserID from EmployeeInfo as E where E.ip=@ip  return @@ERROR 
    end 
      

  4.   

    declare @i int
    exec Time_Insert @ip ,@I output
      

  5.   

    还的问下,另外一个存储过程调用这个存储过程返回的return_id,
    实现select * from where id="return_id"
    怎么写,ip的参数不需要。