alter procedure ck_c
(
@user_name Char(10),
@user_pass Char(10),
@uid int output
)
As
Begin 
 Declare @Exist Int
 
 if Exists(select * From user_all
          where [user_name]=@user_name
           and  user_pass = @user_pass)
   begin
     select @uid = user_all.uid From user_all where [user_name]=@user_name and  user_pass = @user_pass
     set @Exist = 1
   end
 else 
   begin
     set @Exist = 0  
   end
  return @Exist
ENd --调用
declare @s_username char(10)
declare @s_userpass char(10)
declare @i_uid int
declare @i_return int
select @s_username = 'dd',
       @s_userpass = 'cc'
exec @i_return = ck_c @s_username,@user_pass,@i_uid output

解决方案 »

  1.   

    传个uid这个参数,但写了老是报错,请大家指点指点!谢谢@
    @@uid int output改為@uid
    還有想保存輸出的值﹐
    在存儲過程里定義了output型。
    在偉參數的時候一定也要加上在此變量旁邊加上output
    exec procedureName ...@ex_uid output --這個output不能少
      

  2.   

    Create procedure ck_c
    (
    @user_name Char(10),
    @user_pass Char(10),
    @uid int output
    )
    As
    Begin 
     Declare @Exist Int
     select @uid=user_all.uid From user_all 
     where [user_name]=@user_name
     and  user_pass = @user_pass
     
     if @@rowcount=0
      begin
        Select @Exist = 0
        return @Exit
      end
     else 
      begin
        Select @Exist = 1
        return @uid 
      end
      
    ENd