Solved

Data Dictionary

Posted on 1998-07-15
5
258 Views
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.
0
Comment
Question by:rickwinterkorn
  • 2
  • 2
5 Comments
 

Expert Comment

by:zimmy
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.

0
 

Author Comment

by:rickwinterkorn
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:

SELECT OWNER,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE,
 DATA_LENGTH,
DATA_PRECISION,
DATA_SCALE,
 NULLABLE,
COLUMN_ID
FROM ALL_TAB_COLUMNS
WHERE OWNER = dbname



0
 
LVL 2

Expert Comment

by:odessa
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
0
 

Author Comment

by:rickwinterkorn
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.  
0
 

Accepted Solution

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

809 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