Posted by: codeproject | February 28, 2008
SQL SERVER – Find any expression in the database
Leave a response
Categories
- ASP.NET Framework
- ASP.NET Tips
- Cisco
- Conference
- Data Types
- Database Programming
- Eid
- Excel
- General
- GridView
- HTml
- IIS
- Javascript
- Latest Hi-Tech Updates
- MySQL
- Networking
- New Year
- Project Planning
- Qaid e Azam
- Seminar
- SEO
- SQL Server 2005
- SQL Server 2008
- SQL Sever
- SQL Tips and Tricks
- Trouble Shooting
- VB.NET 2005
- Visio
- Visual Studio ASP.NET
- VS 2008
- Workshop
- XML






My colleagues asked me hundred times, how to find a particular columns, table name, stored procedure, views in the database.
Always forgot to remember one query. So for them only
Below query you can any table, stored procedure or views who ever have that expression as a column or object name.
SELECT * FROM SYSOBJECTS WHERE ID IN (SELECT ID FROM SYSCOMMENTS WHERE TEXT LIKE ‘%PRODUC%’)
The query produced all the object names. where ever it finds expression like ‘PRODUC‘
If you wanted to find any table name only then
SELECT * FROM SYSOBJECTS WHERE NAME LIKE ‘%TA%’ and xtype=‘u’
For stored procedure pass xtype=‘p’ and for views xtype=‘v’
Hope next time my friends will visit from my blog to get this query
Rana
Posted in SQL Server 2005, SQL Server 2008, SQL Sever, SQL Tips and Tricks | Tags: Like, Sql Server, SQL Server 2005, SYSCOMMENTS, SYSOBJECTS, Tips, xtype