Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Posts Tagged ‘find database objects

How to query different type database object like table, view, trigger using sysobject

with one comment

 

following is the query for selecting all object from all database

SELECT      name, id, xtype, uid, info, status, base_schema_ver,  replinfo, parent_obj, crdate, ftcatid, schema_ver,  stats_schema_ver, type, userstat, sysstat, indexdel,  refdate,version, deltrig, instrig, updtrig, seltrig,  category, cache
FROM        sys.sysobjects

There are various parameter which you can use as where to specify criteria.

If you want to search certain object type then

XTYPE =

‘U’ For table
‘PK’ For Primary Keys
‘F’ For Foreight Keys
‘V’ For views
‘P’ For stored procedures
‘TR’ For triggers
‘S’ For system objects
‘FN’ Function

 

You can also add like query on name to give specific resultset.

Advertisements

Written by Manish

August 25, 2009 at 4:22 pm

Posted in .NET

Tagged with , ,