Thursday, March 29, 2012

describe table

Oracle has describe table, which will return the SQL Definition of that table...what is the equivalent in MSSQL? I am aware of sp_help table, but that doesn't cut it.
I want to create a table using one of the various GUI tools that are "out there" but I then want to save the resulting SQL DDL, so that I can script future database creates/drops/etc.
Any help appreciated.
BOB
Both Query Analyzer and Enterprise Manager can script DDL from an existing
objects. EM also allows you to save DDL scripts when creating or modifying
objects via the 'save change script' button.
Hope this helps.
Dan Guzman
SQL Server MVP
"bob" <bob@.discussions.microsoft.com> wrote in message
news:BA0FCA03-FD78-4845-9655-00CE08A5B290@.microsoft.com...
> Oracle has describe table, which will return the SQL Definition of that
table...what is the equivalent in MSSQL? I am aware of sp_help table, but
that doesn't cut it.
> I want to create a table using one of the various GUI tools that are "out
there" but I then want to save the resulting SQL DDL, so that I can script
future database creates/drops/etc.
> Any help appreciated.
> BOB
|||If you use Enterprise Manager (one of those various GUI tools ;-)) you can
generate a create table script with the third button from the left.
Jacco Schalkwijk
SQL Server MVP
"bob" <bob@.discussions.microsoft.com> wrote in message
news:BA0FCA03-FD78-4845-9655-00CE08A5B290@.microsoft.com...
> Oracle has describe table, which will return the SQL Definition of that
table...what is the equivalent in MSSQL? I am aware of sp_help table, but
that doesn't cut it.
> I want to create a table using one of the various GUI tools that are "out
there" but I then want to save the resulting SQL DDL, so that I can script
future database creates/drops/etc.
> Any help appreciated.
> BOB
|||Query Analyzer will script any table individually. Just right-click on the
table in the Object Browser and select Script to New Window As > Create.
Enterprise Manager will allow you to script multiple objects to a single
file or script an entire database if you wish.
David Portas
SQL Server MVP
|||Thanks...I was hoping for a non EM solution...a simple bit of SQL (actually, I am using MSDE, so EM is not an option...)
Cheers,
BOB
"Jacco Schalkwijk" wrote:

> If you use Enterprise Manager (one of those various GUI tools ;-)) you can
> generate a create table script with the third button from the left.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "bob" <bob@.discussions.microsoft.com> wrote in message
> news:BA0FCA03-FD78-4845-9655-00CE08A5B290@.microsoft.com...
> table...what is the equivalent in MSSQL? I am aware of sp_help table, but
> that doesn't cut it.
> there" but I then want to save the resulting SQL DDL, so that I can script
> future database creates/drops/etc.
>
>
|||Bob,
There's no TSQL out-of-the-box option to get the CREATE TABLE statement for an existing table. There are bunch
of options, both GUI, client code and TSQL code, however. You might want to start at:
http://www.karaszi.com/sqlserver/inf...ate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"bob" <bob@.discussions.microsoft.com> wrote in message
news:A51ADE49-037D-4CD6-85AB-E169CB524DAF@.microsoft.com...
> Thanks...I was hoping for a non EM solution...a simple bit of SQL (actually, I am using MSDE, so EM is not
an option...)[vbcol=seagreen]
> Cheers,
> BOB
> "Jacco Schalkwijk" wrote:
|||One of the ten commandments at our shop is to SCRIPT EVERYTHING.
That means we make a TEXT file with an extension of .SQL and put our TABLE create right in there. We building indexes and constraints right in that script. We have control over naming our indexes.
We script STORED PROCEDURE creation. We script the GRANTing of rights to SPROCS in the same script.
Changes made in the GUI can get lost and never make it to production servers.
Having EM or QA create a script from the database is flawed - it doesn't have everything associated with that table or sproc...
At least that's the way we do it - and it's been very successful in a rapid development/get the software to the customer scenario over the past 3 years.
"David Portas" wrote:

> Query Analyzer will script any table individually. Just right-click on the
> table in the Object Browser and select Script to New Window As > Create.
> Enterprise Manager will allow you to script multiple objects to a single
> file or script an entire database if you wish.
> --
> David Portas
> SQL Server MVP
> --
>
>

No comments:

Post a Comment