------------------ 系統存儲過程 -------------------
--微軟定義好的,能夠直接使用的存儲過程,叫作系統存儲過程
--system procedure 如:sp_xxx
exec sp_helpdb master 程序員
exec sp_bindrule學習
----------------- 自定義存儲過程 -------------------
--由程序員定義的存儲過程spa
--擴展存儲過程ast
----================== 存儲過程的建立 無參數 ===============---
--定義
create procedure pro
as
begin
declare @x int
set @x=1
while @x<10
begin
print @x
set @x=@x+1
end
end擴展
--調用
exec proselect
--刪除存儲過程
drop procedure pro2程序
--修改
alter procedure pro
as
begin
declare @x int
set @x=1
while @x<10
begin
print @x
set @x=@x+1
end
end查詢
-------============ 存儲過程的建立 有參數 ===============------------ 存儲過程
--定義有參數 存儲過程,實現查詢出學生的成績,按學生姓名模糊查詢。以姓名關鍵字爲參數 【重點】
create procedure por_select @sname varchar(20)
as
begin
select * from student where name like '%'+@sname+'%'
enddb
exec por_select '三'
--查詢存儲過程
exec sp_help por_select
exec sp_helptext por_select
做者還在學習中,發現錯誤的請在評論區留言。 若是有客友以爲文章還行的話,請點波推薦哦👍。 謝謝大家!!