Search..

Wednesday, May 6, 2009

To list all the tables present in a database

This query used to list all the tables present in the database

SELECT name
FROM [servername].[databasename].dbo.sysobjects
WHERE xtype='u' order by name


You can also select the other details like
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

SELECT *
FROM [servername].[databasename].dbo.sysobjects
WHERE xtype='u'