显示数据库中的存储过程__转

本文介绍如何使用 SQL Server 的内置系统表 sysobjects 和系统存储过程 sp_helptext 来查看数据库中的存储过程。通过简单的脚本,可以获取存储过程的详细信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

显示数据库中的存储过程__转

It's no easy trick to see stored procedures in a database programmatically with a scripting language like ASP. If you're using MS Access, you're out of luck. Access provides no way to see the actual meat of a stored procedure although you can get the names of the procedures in the database with the ADOX.Catalog COM object.

But, if you are using SQL Server (like you should be because you care about your data), you have a guaranteed way to view all your stored procedures using two globally-available system objects: the built-in sysobjects system table and the sp_helptext system stored procedure.

With a couple of simple loops, everything about your stored procedures can be viewed and accessed programmatically in just a few lines. Here's the results of the function (I'm allowing you to view the first few procedures only because this method can be pretty resource-intensive. If you want the complete list of procedures I use on this site, you can get it here.) Here's how it looks when called:


CREATE PROCEDURE sp_addAdvertLink 

@m1 DateTime, 
@m2 DateTime, 
@m3 VarChar(20), 
@m4 VarChar(20), 
@m5 VarChar(255), 
@m6 VarChar(255), 
@m7 VarChar(255), 
@m8 VarChar(255) 

AS 
INSERT INTO 
easyAds 

display_date, display_time, display_month, display_day, 
usr_ip_address, usr_browser, display_adName, usr_referer 

VALUES 

@m1, @m2, @m3, @m4, @m5, @m6, @m7, @m8 
)

CREATE PROCEDURE sp_AddMailRecip 

@mIPAddr VarChar(255), 
@mEmailAddr VarChar(255) 

AS 
INSERT INTO 
autoResponder 

IPaddress, emailAddress 

VALUES 

@mIPAddr, @mEmailAddr 
)


CREATE PROCEDURE sp_addUsrAddr 

@mUsr VarChar(255), 
@mFstNme VarChar(255), 
@mLastNme VarChar(255), 
@mAddr1 VarChar(255), 
@mAddr2 VarChar(255), 
@mcity VarChar(255), 
@mstate VarChar(255), 
@mzip VarChar(255), 
@mEmail VarChar(255), 
@mphone VarChar(255), 
@mfax VarChar(255), 
@mcell VarChar(255), 
@mnotes Text 

AS 
INSERT INTO 
dayPlannerAddresses 

usr, firstname, lastname, streetAddress1, streetAddress2, 
city, state, zip, eMailAddress, phone, fax, cell, notes 

VALUES 

@mUsr, @mFstNme, @mLastNme, @mAddr1, @mAddr2, @mcity, @mstate, 
@mzip, @mEmail, @mphone, @mfax, @mcell, @mnotes 
)


------------------sysobjects.asp-------------源程序--------------

<% @ Language = JScript %>
<%
with (Response) {
Buffer = true;
Expires = 0;
Clear();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值