Monday, November 30, 2009

Query to get the table names in a SqlServer db

The following Query will generate a list of the tables in a sqlserver db

select [name] from sysobjects where [xtype] = 'U' order by [name]

Use [xtype] ='PK' for list of primary keys,

[xtype] = 'P' for list of stored procedures,

etc.