Groups | Blog | Home
all groups > sql server new users > january 2006 >

sql server new users : How can I attach a description to a table


Johan
1/16/2006 6:41:02 AM
You can easily enter a description at a table field.

Andrew J. Kelly
1/16/2006 2:54:19 PM
You can use Enterprise Manager in the table designer or you can simply use
the sp called sp_addextendedproperty.

DECLARE @v sql_variant
SET @v = N'This is my Description'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'user', N'dbo',
N'table', N'MyTable', NULL, NULL


--
Andrew J. Kelly SQL MVP


[quoted text, click to view]

David Portas
1/16/2006 11:39:15 PM
[quoted text, click to view]

Why would you do that in the database? Better to put it in a data dictionary
or logical design document instead IMO.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Johan
1/17/2006 4:09:02 AM
My experience is that developers/dba's don't like updating models/documents.
So it is difficult to maintain good documentation.

When the description is directly attached to the table, it is easier to
maintain and you can create documentation automatically via the system tables.

Regards,
Johan Theunissen

[quoted text, click to view]
Johan
1/17/2006 4:18:04 AM
When I execute this sp, it works "(1 row(s) affected)".

But where is the descripstion stored?

[quoted text, click to view]
Johan
1/17/2006 4:25:03 AM
What does the N' mean in front of the parameters?

[quoted text, click to view]
Sue Hoegemeier
1/17/2006 7:24:42 AM
The description is stored in sysproperties.
The N in front of a string indicates it's a unicode string.

-Sue

On Tue, 17 Jan 2006 04:25:03 -0800, "Johan"
[quoted text, click to view]
Andrew J. Kelly
1/17/2006 1:54:28 PM
It is stored internal to the db in system tables.

--
Andrew J. Kelly SQL MVP


[quoted text, click to view]

Johan
1/17/2006 11:37:05 PM
When I run the sp, it generates the following values in tblproperties

field id = number corresponding to the id of the sysobjects table
smallid = 0 (what is this?)
type = 3 (what is this?)
name = name in sp
value = <Binary> (Why is this not the description string?)



[quoted text, click to view]
Sue Hoegemeier
1/18/2006 8:31:41 AM
It's an undocumented system table so it shouldn't really
matter. id is the first column, not field id. It's the id
for the table. Value is the description string stored in
binary format. I can't remember the others off the top of my
head - you can look at the system stored procedure
sp_validatepropertyinuput to figure those out.
I'm not sure why it would matter though.

-Sue

On Tue, 17 Jan 2006 23:37:05 -0800, "Johan"
[quoted text, click to view]
Gail Erickson [MS]
1/18/2006 10:35:01 AM
If you are just trying to return the extended properties on an object, then
you should use the documented method for doing so. In SQL Server 2000, the
correct method is the fn_listextendedproperty function. Here's a little
example that illustrates how to use it.

CREATE table T1 (id int , name char (20))
EXEC sp_addextendedproperty 'caption', 'Employee ID', 'user', dbo,
'table', 'T1', 'column', id
EXEC sp_addextendedproperty 'caption', 'Employee Name', 'user', dbo,
'table', 'T1', 'column', name
SELECT * FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table',
'T1', 'column', default)

If you're using SQL Server 2005, use the sys.extended_properties catalog
view instead. It's easier to use than the function.

Search Books Online for extended properties for details.
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights

[quoted text, click to view]

Robert
1/22/2006 11:27:06 AM

[quoted text, click to view]

SchemaToDoc (http://www.schematodoc.com) has as part of its interface a
way to easily view and enter descriptions for all of the tables and
fields in your database. These descriptions get stored as extended
properties in your database. SchemaToDoc can then produce a Word
document that documents the structure of your database and include in
that document the table and field descriptions that you entered.
AddThis Social Bookmark Button