Thursday, January 15, 2009

Select table names in SQL Server

The following query will give you a list of the table names of a database in SQL Server. Note that this is a query done directly into the sysobjects which is not recommended for production purposes, but it could get you out of problems if you need the table names from the database.

The query is:

select [name] from dbo.sysobjects where xtype='U'

If you are curious enough, you will see that you should be able to get the Creation Date too:

select [name],[crdate] from dbo.sysobjects where xtype='U'

Simple, easy and straight to the point. :D

No comments: