Home > Archive > MS SQL Server > December 2006 > Need help w/ scripting tables









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Need help w/ scripting tables
tootsuite@gmail.com

2006-12-06, 7:12 pm

Hi,

Every month I am tasked with scripting out all the tables for several
databases. Using SQL Server 2005's Mgmt Studio, scripting by hand takes
*forever* and is very tedious.

I would rather find a way to do this automatically using some kind of
script. For example, I need it to loop through all the tables in a
given database, then script out the table definition, including
indexes, constraints, etc - to a local directory on the server.

I managed to find a way to do this for stored procedures using
sp_helptext and xp_cmdshell. However sp_helptext does not script out
tables.

I am certain someone else has a solution to this problem, and that
there is a script out there that does exactly what I need. I am hoping
someone can provide this script or point me in the right direction.

Thanks much

KristinaDBA@gmail.com

2006-12-06, 7:12 pm

Have you seen the redgate program? it creates scripts and compares
databases. Their software is pretty cheap and has saved my neck many
times:

http://www.red-gate.com/

Hope this helps - Kristina

tootsuite@gmail.com wrote:
> Hi,
>
> Every month I am tasked with scripting out all the tables for several
> databases. Using SQL Server 2005's Mgmt Studio, scripting by hand takes
> *forever* and is very tedious.
>
> I would rather find a way to do this automatically using some kind of
> script. For example, I need it to loop through all the tables in a
> given database, then script out the table definition, including
> indexes, constraints, etc - to a local directory on the server.
>
> I managed to find a way to do this for stored procedures using
> sp_helptext and xp_cmdshell. However sp_helptext does not script out
> tables.
>
> I am certain someone else has a solution to this problem, and that
> there is a script out there that does exactly what I need. I am hoping
> someone can provide this script or point me in the right direction.
>
> Thanks much


Tibor Karaszi

2006-12-06, 7:12 pm

Use SMO:

http://www.karaszi.com/SQLServer/ i...ript
.asp


--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/



<tootsuite@gmail.com> wrote in message news:1165430736.628285.132760@79g2000cws.googlegroups.com...
> Hi,
>
> Every month I am tasked with scripting out all the tables for several
> databases. Using SQL Server 2005's Mgmt Studio, scripting by hand takes
> *forever* and is very tedious.
>
> I would rather find a way to do this automatically using some kind of
> script. For example, I need it to loop through all the tables in a
> given database, then script out the table definition, including
> indexes, constraints, etc - to a local directory on the server.
>
> I managed to find a way to do this for stored procedures using
> sp_helptext and xp_cmdshell. However sp_helptext does not script out
> tables.
>
> I am certain someone else has a solution to this problem, and that
> there is a script out there that does exactly what I need. I am hoping
> someone can provide this script or point me in the right direction.
>
> Thanks much
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com