SQL 如何统计一个数据库中SQL Server中的所有存储过程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4629011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 08:48:43 来源:igfitidea点击:
How to count all stored procedures in the SQL Server for a database?
提问by NoviceToDotNet
How can I count all stored procedures which are written by me in my database?
如何计算我在数据库中编写的所有存储过程?
回答by Conrad Frix
select Count(*) from sys.procedures
And as Philip Kelley noted this is sql 2005 and up
正如 Philip Kelley 指出的,这是 sql 2005 及更高版本
回答by Neil Knight
To get the Stored Procedure count:
要获取存储过程计数:
SELECT COUNT(*) SPCOUNT
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE='PROCEDURE'
or:
或者:
SELECT COUNT(*)
FROM sys.procedures
or:
或者:
SELECT COUNT(*)
FROM sys.sysobjects
WHERE xtype = 'P'
Hope one of these help.
希望其中之一有所帮助。
回答by Iyyappan
-- Information about table --
SELECT * FROM sys.sysobjects WHERE xtype = 'U'
-- Information about Stored Procedure --
SELECT * FROM sys.sysobjects WHERE xtype = 'P'
-- Information about Functions --
SELECT * FROM sys.sysobjects WHERE xtype = 'FN'
-- Information about Views --
SELECT * FROM sys.sysobjects WHERE xtype = 'V'
回答by Jason
select count(name)
from sys.objects
where type = 'P'
回答by Lamak
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
回答by Doliveras
select count(*)
from sysobjects
where xtype='P'