Home [SQL] 取得程序資訊 SP_HELP、SP_HELPTEXT
Post
Cancel

[SQL] 取得程序資訊 SP_HELP、SP_HELPTEXT

取得程序資訊

1
2
3
sp_help --取得一覽表
sp_help procedure_name --取得SP資訊
sp_helptext procedure_name --取得SP定義

範例

假如有一個名為「usp_Test」的預存程序,想要查看SP的資訊,可以執行下面三種方式

1
2
3
sp_help 
sp_help usp_Test --取得SP資訊
sp_helptext usp_Test --取得SP定義

執行結果:

`` /* 取得定義:執行 「sp_helptext usp_Test」的結果 */

Text create procedure usp_Test
@id int
as
begin
select sum(數量) as “販賣數量”
from 販賣資料
where 商品ID = @id
end
```

This post is licensed under CC BY 4.0 by the author.