Solved

Data Dictionary

Posted on 1998-07-15
5
247 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PL/SQL query 14 51
SQL server 2008 SP4 29 35
SQL JOIN 6 39
Sql query to Stored Procedure 6 21
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now