Solved

Data Dictionary

Posted on 1998-07-15
5
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

740 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