SQL Server在存储过程中查找关键字

在存储过程中查找(搜索,查询)关键字

SQL 查找存储过程中出现过的文字怎么查询呢?

select b.name
from 数据库名.dbo.syscomments a, 数据库名.dbo.sysobjects b
where a.id=b.id  and b.xtype='p' and a.text like '%key words%'

order by name

 

create PROCEDURE [dbo].[_searchSP]
     @keywords nvarchar(100)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    select b.name
    from dbo.syscomments a, dbo.sysobjects b
    where a.id=b.id  and b.xtype='p' and a.text like '%' + @keywords+ '%'
    order by name
END

go

create PROCEDURE [dbo].[_searchTableFunction]
     @keywords nvarchar(100)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    select b.name
    from dbo.syscomments a, dbo.sysobjects b
    where a.id=b.id  and b.xtype='TF' and a.text like '%' + @keywords+ '%'
    order by name
END

go

posted @ 2010-02-25 21:22  emanlee  阅读(5885)  评论(0编辑  收藏  举报