mysql,sqlserver存储过程的创建及执行
sqlserver:
创建不带参数的存储过程:
CREATE PROCEDURE 'ProName'
AS
SELECT * FROM [dbo].[TABLE_1]
go
创建带参数的存储过程:
CREATE PROCEDURE 'ProName'
@params varchar(10)
AS
SELECT * FROM TABLE_1 where student_id=@params
go
执行存储过程:
exec 'ProName' 'paramsName'
查看所有的存储过程:
select * from sysobjects where type='P'
查看某个存储过程的详细内容:
SELECT text FROM syscomments WHERE id = ( SELECT id FROM sysobjects WHERE name = 'ProName')
删除存在的存储过程:
if Exists(select name from sysobjects where NAME = 'ProName' and type='P')
drop procedure 'ProName'
mysql:
创建不带参数的存储过程:
delimiter //
create procedure procedure_name()
begin
select * from table_name;
end
创建带参数的存储过程:
delimiter //
create procedure procedure_name(a int)
begin
select * from table_name where id=a;
end
查看所有的存储过程:
show PROCEDURE status;
查看某个存储过程的详细内容:
show create procedure procedure_name;
执行不带参数的存储过程:
call procedure_name();
执行带参数的存储过程:
call procedure_name(param);
删除存在的存储过程:
DROP PROCEDURE IF EXISTS procedure_name;