SQL: Tables and Columns and Lists Oh My!
Author: jason
Date: 2014-01-24 14:37:56
Category: Musing

Use the following two procedures to get a listing of tables and columns associated with a table.

The procedure sp_tables will return a list of all tables in a database. To limit the results down the procedure can take a number of parameters. One of the parameters is @TABLE_TYPE. The Quote and Apostrophe positioning are important for this parameter. Inside the Quotes you can put several types, such as: "'TABLE', 'VIEW'"

The procedure sp_columns will return all the field/column information for a specific table.


USE MyTest;
EXEC sp_tables @TABLE_TYPE = "'TABLE'";
EXEC sp_columns myTable;


jason @ jasonthomasfrance.com - www.masterstationlog.com - copyright 2009