日期:2014-05-16  浏览次数:20762 次

mssql与mysql区别之四:存储过程

mssql:

create procedure proc_xx3
@o varchar(100) output,
@name varchar(100)='a',
@nname varchar(100)='b'
as
declare @a int
set @a = 1
select @o=xx.name from xx where xx.id=@a
select * from xx where xx.name=@name or xx.name=@nname or xx.id=@a
go

declare @z varchar(100)
exec proc_xx3 @z output,'b','b'
print 'name=' + @z

?

mysql:

create PROCEDURE p1(in v INT,out z VARCHAR(100))
begin
select @n:=total FROM `month` where total=v;
if @n=1 THEN
select @n;
ELSE
select 'no';
END IF;
set z = 2;
end;

call p1(286,@z);
select @z;
?