Friday, February 24, 2012

adding field descriptions

Hi.
I use a SQL file to create my tables. I would like to add field descriptions
to each field, but cannot figure the format:
CREATE TABLE t_012(
field1 nvarchar(22) default NULL description='my desc goes here',
field 2 integer default NULL
);
Could someone please tell me the correct way to do this?
TIA
JoeB
Joe,
When you have questions like that a good way to find out how some of them
are done is to run a profiler trace and then create a table in EM. If you
add a description in EM you will see the commands used to accomplish this.
Another and sometimes easier way is to use the table designer in Em to
create the table along with the extended properties that you want and then
before saving click on the 3rd (I think) toolbar button from the left and it
will let you script out what EM will do. Just be somewhat careful in that
EM does not always do it the most efficient way. For instance it will
usually make a new copy of a table when adding or altering columns instead
of just using ALTER TABLE.
Andrew J. Kelly SQL MVP
"JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
news:umpmpiRhEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Hi.
> I use a SQL file to create my tables. I would like to add field
descriptions
> to each field, but cannot figure the format:
>
> CREATE TABLE t_012(
> field1 nvarchar(22) default NULL description='my desc goes here',
> field 2 integer default NULL
> );
>
> Could someone please tell me the correct way to do this?
>
> TIA
>
> JoeB
>
|||How do i run a profiller trace or see what the GUI is actually doing?
-- I didnt think it was posible to see the real scripting that the GUI uses!
As you can tell, im a newbie!
Joe
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:%23v4BpmRhEHA.3916@.TK2MSFTNGP11.phx.gbl...
> Joe,
> When you have questions like that a good way to find out how some of them
> are done is to run a profiler trace and then create a table in EM. If you
> add a description in EM you will see the commands used to accomplish this.
> Another and sometimes easier way is to use the table designer in Em to
> create the table along with the extended properties that you want and then
> before saving click on the 3rd (I think) toolbar button from the left and
> it
> will let you script out what EM will do. Just be somewhat careful in that
> EM does not always do it the most efficient way. For instance it will
> usually make a new copy of a table when adding or altering columns instead
> of just using ALTER TABLE.
>
> --
> Andrew J. Kelly SQL MVP
>
> "JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
> news:umpmpiRhEHA.3428@.TK2MSFTNGP11.phx.gbl...
> descriptions
>
|||In EM click on the menu for "Tools" and then select "Profiler". Then when
that tool opens choose "File - New - Trace" . Connect to your server and
when the trace properties dialog appears go to the "Events" tab. You might
want to make sure you have the "TSQL SQL:StmtStarting" selected and then
run the trace. Now what you do in EM will show up in there.
Andrew J. Kelly SQL MVP
"JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
news:%235Df10RhEHA.2764@.TK2MSFTNGP11.phx.gbl...
> How do i run a profiller trace or see what the GUI is actually doing?
> -- I didnt think it was posible to see the real scripting that the GUI
uses![vbcol=seagreen]
>
> As you can tell, im a newbie!
>
> Joe
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:%23v4BpmRhEHA.3916@.TK2MSFTNGP11.phx.gbl...
them[vbcol=seagreen]
you[vbcol=seagreen]
this.[vbcol=seagreen]
then[vbcol=seagreen]
and[vbcol=seagreen]
that[vbcol=seagreen]
instead
>
|||Cheers,
Does anyone else have SQL server2000 SP3 lockup during EM 15-20 times /
day?
Jeo
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:%23KCcjIWhEHA.2544@.TK2MSFTNGP10.phx.gbl...
> In EM click on the menu for "Tools" and then select "Profiler". Then when
> that tool opens choose "File - New - Trace" . Connect to your server and
> when the trace properties dialog appears go to the "Events" tab. You
> might
> want to make sure you have the "TSQL SQL:StmtStarting" selected and then
> run the trace. Now what you do in EM will show up in there.
> --
> Andrew J. Kelly SQL MVP
>
> "JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
> news:%235Df10RhEHA.2764@.TK2MSFTNGP11.phx.gbl...
> uses!
> them
> you
> this.
> then
> and
> that
> instead
>
|||The diagram editor in SQL Server Enterprise Manager (and in Access) stores a
columns description as an 'extended property' named MS_Description
These can also be seen usgin SQL Query Analyzer by navigating to the
columns, right clicking on it, selecting Extended properties
They can also be editted using these stored procs (quote from BOL):
a.. sp_addextendedproperty
Adds a new extended property to a database object.
b.. sp_updateextendedproperty
Updates the value of an existing extended property.
c.. sp_dropextendedproperty
Drops an existing extended property.
Good luck
Malcolm Cook - mec@.stowers-institute.org
Database Applications Manager - Bioinformatics
Stowers Institute for Medical Research - Kansas City, MO USA
"JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
news:umpmpiRhEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Hi.
> I use a SQL file to create my tables. I would like to add field
descriptions
> to each field, but cannot figure the format:
>
> CREATE TABLE t_012(
> field1 nvarchar(22) default NULL description='my desc goes here',
> field 2 integer default NULL
> );
>
> Could someone please tell me the correct way to do this?
>
> TIA
>
> JoeB
>

No comments:

Post a Comment