Manish Pansiniya's Blog

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

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


‘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.


Written by Manish

August 25, 2009 at 4:22 pm

Posted in .NET

Tagged with , ,

One Response

Subscribe to comments with RSS.

  1. Really a Cool


    September 12, 2009 at 3:07 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: