--查询所有存储过程
select * from sys.objects where type = 'P';
--修改存储过程
alter proc proc_get_studentasselect * from student;
--调用、执行存储过程
exec proc_get_student;
--------------------------------
--创建存储过程
if (exists (select * from sys.objects where name = 'proc_get_student')) drop proc proc_get_studentgocreate proc proc_get_studentas select * from student;
-----------------------------------
--带参存储过程
if (object_id('proc_find_stu', 'P') is not null) drop proc proc_find_stugocreate proc proc_find_stu(@startId int, @endId int)as select * from student where id between @startId and @endIdgoexec proc_find_stu 2, 4;
-------------------------------------
--带通配符参数存储过程
if (object_id('proc_findStudentByName', 'P') is not null) drop proc proc_findStudentByNamegocreate proc proc_findStudentByName(@name varchar(20) = '%j%', @nextName varchar(20) = '%')as select * from student where name like @name and name like @nextName;goexec proc_findStudentByName;exec proc_findStudentByName '%o%', 't%';
转载请注明原文地址: https://www.6miu.com/read-57235.html