The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Find Sql Stored Procedures, Tables and Views Containing Some Text

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Raymond Lewallen

Posts: 312
Nickname: rlewallen
Registered: Apr, 2005

Raymond Lewallen is a .Net developer and Sql Server DBA
Find Sql Stored Procedures, Tables and Views Containing Some Text Posted: Aug 15, 2005 6:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Raymond Lewallen.
Original Post: Find Sql Stored Procedures, Tables and Views Containing Some Text
Feed Title: Raymond Lewallen
Feed URL: /error.htm?aspxerrorpath=/blogs/raymond.lewallen/rss.aspx
Feed Description: Patterns and Practices, OOP, .Net and Sql
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Raymond Lewallen
Latest Posts From Raymond Lewallen

Advertisement

Last week, John posted a T-Sql script to find all stored procedures that contain some text. Along those sames lines, I have expanded what he has done to also include returning tables and views that have column names that contain the same text.

CREATE PROCEDURE sp_find_objects_containing

            @search varchar(128)

AS

 

SET @search = '%' + @search + '%'

 

SELECT o.name As "Stored Procedures"

            FROM SYSOBJECTS o INNER JOIN SYSCOMMENTS c

                        ON o.id = c.id

            WHERE c.text LIKE @search

                        AND o.xtype = 'P'

            GROUP BY o.name

            ORDER BY o.name

 

SELECT o.name As "Views"

            FROM SYSOBJECTS o INNER JOIN SYSCOMMENTS c

                        ON o.id = c.id

            WHERE c.text LIKE @search

                        AND o.xtype = 'V'

            GROUP BY o.name

            ORDER BY o.name

 

SELECT o.name As "Tables"

            FROM SYSCOLUMNS c INNER JOIN SYSOBJECTS o

                        ON c.id = c.id

                        INNER JOIN MASTER.DBO.SYSTYPES t

                        ON c.xtype = t.xtype

            WHERE o.name LIKE @search

                        AND o.Type = 'U'

            GROUP BY o.name

            ORDER BY o.name

GO

Read: Find Sql Stored Procedures, Tables and Views Containing Some Text

Topic: INETA Community Launch Team Previous Topic   Next Topic Topic: Updated MSH Syntax Highlighting For VIM

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use