dbTalk Databases Forums  

Design Table; Columns/Description get with SP???

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Design Table; Columns/Description get with SP??? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
vesta
 
Posts: n/a

Default Design Table; Columns/Description get with SP??? - 09-18-2007 , 11:29 AM






Hi,

I'm using stored procedures to create an online data dictionary for
all of our dbs and I thought it would be very cool if there was a way
that I could somehow pull the columns description entered in the table
design view (lower pane) of EM. I have poked around, but have not
found a way. It is my suspcion that this may be impossible. Does any
smart person out there know?

Also want to pull pks and fks and other constraints, which I think I
can figure out how to do, but if anyone has any pointers, that would
also be appreciated.

Many Thanks,

Georgia


Reply With Quote
  #2  
Old   
Roy Harvey (MVP)
 
Posts: n/a

Default Re: Design Table; Columns/Description get with SP??? - 09-18-2007 , 11:51 AM






That description is stored as an extended property. Look at the
documentation of function fn_listextendedproperty for instructions on
how to retrieve this.

Roy Harvey
Beacon Falls, CT

On Tue, 18 Sep 2007 09:29:46 -0700, vesta <vesta0424 (AT) gmail (DOT) com> wrote:

Quote:
Hi,

I'm using stored procedures to create an online data dictionary for
all of our dbs and I thought it would be very cool if there was a way
that I could somehow pull the columns description entered in the table
design view (lower pane) of EM. I have poked around, but have not
found a way. It is my suspcion that this may be impossible. Does any
smart person out there know?

Also want to pull pks and fks and other constraints, which I think I
can figure out how to do, but if anyone has any pointers, that would
also be appreciated.

Many Thanks,

Georgia

Reply With Quote
  #3  
Old   
vesta
 
Posts: n/a

Default Re: Design Table; Columns/Description get with SP??? - 09-18-2007 , 02:32 PM



It looks to me like you create your extended properties with this
function. Are there any default functions to get the information that
has been manually entered in the description field?

Georgia


On Sep 18, 12:51 pm, "Roy Harvey (MVP)" <roy_har... (AT) snet (DOT) net> wrote:
Quote:
That description is stored as an extended property. Look at the
documentation of function fn_listextendedproperty for instructions on
how to retrieve this.

Roy Harvey
Beacon Falls, CT



On Tue, 18 Sep 2007 09:29:46 -0700, vesta <vesta0... (AT) gmail (DOT) com> wrote:
Hi,

I'm using stored procedures to create an online data dictionary for
all of our dbs and I thought it would be very cool if there was a way
that I could somehow pull the columns description entered in the table
design view (lower pane) of EM. I have poked around, but have not
found a way. It is my suspcion that this may be impossible. Does any
smart person out there know?

Also want to pull pks and fks and other constraints, which I think I
can figure out how to do, but if anyone has any pointers, that would
also be appreciated.

Many Thanks,

Georgia- Hide quoted text -

- Show quoted text -



Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Design Table; Columns/Description get with SP??? - 09-18-2007 , 04:25 PM



vesta (vesta0424 (AT) gmail (DOT) com) writes:
Quote:
It looks to me like you create your extended properties with this
function. Are there any default functions to get the information that
has been manually entered in the description field?
No, functions don't create anything, they can only retrieve data. To
add an extended property from T-SQL, you use sp_addextendedproperty.

I cannot really give any examples of using either, because I have not
used extended properties myself very much. Or rather not at all.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #5  
Old   
Roy Harvey (MVP)
 
Posts: n/a

Default Re: Design Table; Columns/Description get with SP??? - 09-18-2007 , 04:40 PM



I used Management Studio from SQL Server 2005 to generate a script of
creating a table with one column, and a description on that column.
Note the use of sp_addextendedproperty under the covers to save the
description.

/* To prevent any potential data loss issues, you should review this
script in detail before running it outside the context of the database
designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Table_1
(
A int NULL
) ON [PRIMARY]
GO
DECLARE @v sql_variant
SET @v = N'Testing Testing Testing'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA',
N'dbo', N'TABLE', N'Table_1', N'COLUMN', N'A'
GO
COMMIT

And now we retrieve the description:

SELECT *
FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table',
'Table_1', 'column', default)

objtype objname name value
---------- ---------- ------------------ -------------------------
COLUMN A MS_Description Testing Testing Testing

(1 row(s) affected)

Roy Harvey
Beacon Falls, CT

On Tue, 18 Sep 2007 12:32:28 -0700, vesta <vesta0424 (AT) gmail (DOT) com> wrote:

Quote:
It looks to me like you create your extended properties with this
function. Are there any default functions to get the information that
has been manually entered in the description field?

Georgia


On Sep 18, 12:51 pm, "Roy Harvey (MVP)" <roy_har... (AT) snet (DOT) net> wrote:
That description is stored as an extended property. Look at the
documentation of function fn_listextendedproperty for instructions on
how to retrieve this.

Roy Harvey
Beacon Falls, CT



On Tue, 18 Sep 2007 09:29:46 -0700, vesta <vesta0... (AT) gmail (DOT) com> wrote:
Hi,

I'm using stored procedures to create an online data dictionary for
all of our dbs and I thought it would be very cool if there was a way
that I could somehow pull the columns description entered in the table
design view (lower pane) of EM. I have poked around, but have not
found a way. It is my suspcion that this may be impossible. Does any
smart person out there know?

Also want to pull pks and fks and other constraints, which I think I
can figure out how to do, but if anyone has any pointers, that would
also be appreciated.

Many Thanks,

Georgia- Hide quoted text -

- Show quoted text -


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.