Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Data Dictionary from within SQL Server 2000


Data Dictionary from within SQL Server 2000

Author
Message
mcurnutt
mcurnutt
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 1
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/mcurnutt/datadictionaryfromwithinsqlserver2000.asp



ckempste
ckempste
SSC Eights!
SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)

Group: General Forum Members
Points: 885 Visits: 1
Nice article Mindy, very informative.


Chris Kempster
www.chriskempster.com
Author of "SQL Server Backup, Recovery & Troubleshooting"
Author of "SQL Server 2k for the Oracle DBA"
Antares686
Antares686
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: Moderators
Points: 8424 Visits: 780
I have found this usefull already and have been using it a while. Good article on the subject.



Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36000 Visits: 18728
Nice article. I too tried this last year, but was a little ticked that I had to use a cursor to get this info. This should be queryable for all tables, but ...

Anyway, well written and a useful technique.

Steve Jones
steve@dkranch.net

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
mcurnutt
mcurnutt
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 1
Thanks for all your comments!

Mindy



G.R.Prithiviraj Kulasingham
G.R.Prithiviraj Kulasingham
SSC-Addicted
SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)SSC-Addicted (427 reputation)

Group: General Forum Members
Points: 427 Visits: 367
I saw your article only today.
It is very usefull, and practical.
I learned so many new things in your article.

Thanks, Keep it up.

Preethi

Cheers,
Prithiviraj Kulasingham

http://preethiviraj.blogspot.com/
swampy
swampy
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 1
Thankyou - this is exactly the answer I have been looking for!!



bnordberg
bnordberg
SSC Veteran
SSC Veteran (287 reputation)SSC Veteran (287 reputation)SSC Veteran (287 reputation)SSC Veteran (287 reputation)SSC Veteran (287 reputation)SSC Veteran (287 reputation)SSC Veteran (287 reputation)SSC Veteran (287 reputation)

Group: General Forum Members
Points: 287 Visits: 569
Great idea. I usually find it better to use the information_schema views so I altered your stored procedure as follows

select
o.[table_name] as 'table_name',
c.ordinal_position as 'column_order',
c.[column_name] as 'column_name',
e.value as 'column_description',
C.DATA_TYPE as Type,
coalesce(numeric_precision,character_maximum_length,0) as Length,
coalesce(numeric_scale,0) as [Decimal Pos],
C.COLUMN_DEFAULT AS [Default]
from information_schema.tables o inner join information_schema.columns c on o.table_name =
c.table_name
left join ::FN_LISTEXTENDEDPROPERTY(N'MS_Description',
N'user',N'dbo',N'table', @table_name, N'column', null) e on c.column_name = e.objname
where o.table_name = @table_name

Thanks



DirkFrazier
DirkFrazier
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 1
I've been exploring this topic for a few days and noticed that the system table sysproperties contained records identified as MS_Description with <Binary> data in the 'value' column. I wrote the following query which returns these records matched with their corresponding records in sysobjects and syscolumns:

SELECT TOP 100 PERCENT dbo.sysobjects.name AS [Table Name], dbo.syscolumns.name AS [Field Name], dbo.systypes.name AS [Data Type],
dbo.syscolumns.length,
dbo.syscolumns.prec AS [Precision], CONVERT(varchar(500), dbo.sysproperties.[value]) AS Description

FROM
dbo.sysobjects INNER JOIN
dbo.syscolumns ON dbo.sysobjects.id = dbo.syscolumns.id INNER JOIN
dbo.sysproperties ON dbo.syscolumns.id = dbo.sysproperties.id AND dbo.syscolumns.colid = dbo.sysproperties.smallid INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype

GROUP BY dbo.sysobjects.name, dbo.syscolumns.colid, dbo.syscolumns.name, dbo.systypes.name, dbo.syscolumns.length, dbo.syscolumns.prec,
dbo.sysproperties.[value]

ORDER BY dbo.sysobjects.name, dbo.syscolumns.colid

I'm pretty new at this stuff, so my question is, is this any different than Mindy's solution or am I missing something?



Peter Brightman
Peter Brightman
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 1
Article is cool, now i know how to query the data dictionary. However i have created my own SQL statement that i use with MS Query, where i cannot define stored procedures but just SQL statements. Here are two simple statements that queries 1. all tables, 2. all tables with all columns.

1. tables

SELECT sysobjects.name 'Table-name'
FROM sysobjects sysobjects
WHERE (sysobjects.type='U') AND (sysobjects.status>1)
ORDER BY sysobjects.name

2. tables with columns

SELECT sysobjects.name 'Table-name', syscolumns.name 'Column-name', syscolumns.length, syscolumns.xprec, syscolumns.xscale, syscolumns.colid, syscolumns.bitpos, syscolumns.isnullable
FROM syscolumns syscolumns, sysobjects sysobjects
WHERE (sysobjects.type='U') AND (sysobjects.id=syscolumns.id)
ORDER BY sysobjects.name, syscolumns.colid

cheers, Peter



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search