Data Dictionary

Posted on 1998-07-15
Last Modified: 2010-05-18
Looking for a SELECT statement that will retreive the database Table Names, FieldNames ,Field  Descriptions, Feild Types, Field Sizes, Nullable, , etc.. for a database in MS SQL SERVER.
Question by:rickwinterkorn
  • 2
  • 2

Expert Comment

ID: 1091776
get positioned in the database in question 'USE dbname'

The following will get you the name and an id number for all the tables:
select id, name from sysobjects where type = 'U' order by name

Substituting each of the id numbers from the previous query into
the following will get you a bunch of stuff about each column in each table.
select * from syscolumns where id = <number>

You can probably figure out what some of the results of this query mean (length, for example). For other stuff you may have to set up a sample table and play with it to find out what 'offset' and 'status' mean.

See Appendix A in Microsoft's Transact SQL Reference for the relationships of all the system tables. Note that there is a system catalog and a database catalog. The system catalog has systemwide data. Each database has its own database catalog with
information specific to that database.

Good luck.


Author Comment

ID: 1091777
Here is an example of what I'm looking for; this is the select statement for Oracle, Sybase has a similar one,  and I'm looking for the similar syntax in MS SQL Server:

WHERE OWNER = dbname


Expert Comment

ID: 1091778
I think zimmy has fully answered to your question if you want to do same as in your example just make a view form syscoloumns and sysobjects

Author Comment

ID: 1091779
Ok Thanks Zimmy and Odessa..I'll look into it.  Zimmy I'll credit your previous answer, just make a quick note so I can respond to accept it. Again thanks.  

Accepted Solution

zimmy earned 50 total points
ID: 1091780
OK. Thanks. And thanks, Odessa.

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server Select - find rows created in last 6 months 4 38
sql server concatenate fields 10 36
hyperlink data type in SQL 3 28
Linked Server Issue with SQL2012 3 26
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question