现在要把oracle的存储过程改成sql server 2000 的,各位能不能给点 sql server 的例子看看,最好是由返回值的。

解决方案 »

  1.   

    CREATE PROCEDURE Admin_UserExists(@UserName varchar(100),@nReturn int =0 Output)
    AS
    select @nReturn=0 if EXISTS(select  UserName   from  T_Users where UserName = @UserName)
    begin
    select @nReturn=1
    end
    return @nReturnGO
      

  2.   


    CREATE PROCEDURE [dbo].GetTitle
    @id bigint,   -- This is the input parameter.
    @title nvarchar(210) OUTPUT -- This is the output parameter.
    AS  SELECT top 1 @title = isnull([title],'')
    FROM [book]
    WHERE [id] <= @id AND [id] >= @idRETURNGO