Blog Stats
  • Posts - 8
  • Articles - 0
  • Comments - 4
  • Trackbacks - 0

 

In SQL Server, search ALL objects for text

Persons familiar with TOAD for Oracle know about the fairly elaborate search function that lets you search for particular text in procedures, functions, views, column names, triggers, pretty much anything.

There’s a way to do that in SQL Server as well, though you kind of have to "do it yourself." 

Use the query below.  Make sure that you are "in" the database that you mean to search before you run this query.

select * from sysobjects o, syscomments c where o.id=c.id

and c.text like '%your search text here%'

You can also limit your search by object type.  For example:

select * from sysobjects o, syscomments c where o.id=c.id

and c.text like '%mysearchstring%'

and xtype='P' --search stored procedures only

The complete list of types is below.  For more information, see:

http://articles.techrepublic.com.com/5100-9592_11-6142579.html

  • C: Check constraint
  • D: Default constraint
  • F: Foreign Key constraint
  • L: Log
  • P: Stored procedure
  • PK: Primary Key constraint
  • RF: Replication Filter stored procedure
  • S: System table
  • TR: Trigger
  • U: User table
  • UQ: Unique constraint
  • V: View
  • X: Extended stored procedure
  • Print posted @ Monday, June 16, 2008 3:55 PM


    Feedback

    No comments posted yet.


    Post a comment





     

    Please add 6 and 5 and type the answer here:

     

     

    Copyright © Edward Buatois