SQL 查找存在某内容的存储过程

–查找存在某表名的存储过程

SELECT distinct b.name from syscomments a,sysobjects b 
 WHERE a.id=b.id and a.TEXT LIKE '%你要查找的表名%'

–查找存在某内容的存储过程

SELECT NAME FROM sysobjects o, syscomments s 
WHERE o.id = s.id 
AND TEXT LIKE '%你要查找的内容%' 
AND o.xtype = 'P'

–查找存在某内容的存储过程名称及存储过程内容

SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
FROM INFORMATION_SCHEMA.ROUTINES 
WHERE ROUTINE_DEFINITION LIKE '%你要查找的内容%' 
AND ROUTINE_TYPE='PROCEDURE'

 –查询数据库中所有的表名及行数

SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1))
ORDER BY b.rows DESC

查询所有的标明及空间占用量\行数

select
object_name(id) tablename,
8*reserved/1024 reserved,
rtrim(8*dpages)+'kb' used,
8*(reserved-dpages)/1024 unused,
8*dpages/1024-rows/1024*minlen/1024 free,
rows
--,*
from sysindexes
where indid=1
order by tablename,reserved desc

//查询所有表明

select name from sysobjects where xtype='u'

select * from sys.tables

 

转载于:https://www.cnblogs.com/weifeng123/p/9752874.html

    原文作者:weixin_30418341
    原文地址: https://blog.csdn.net/weixin_30418341/article/details/97923244
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞