General discussion

Locked

How to Script a MS SQL Server Table

By geoff.walter ·
Besides using MS SQL Server Enterprise Manager, does anyone have a method of scripting a Microsoft SQL Server table and it's related indexes into TSQL code? I want to create a SQL Server job to DROP & CREATE a table, but instead of 'hard coding' the TSQL code in a jobstep to create my table, I would prefer to generate the TSQL CREATE command immediately prior to the DROP step, and then run that TSQL script to recreate my table after doing the DROP.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How to Script a MS SQL Server Table

by Joseph Moore In reply to How to Script a MS SQL Se ...

Here is a page on the Create Table syntax in TSQL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqlce/sqlceref_8g9x.asp
(please remove any spaces)

hope this helps

Collapse -

How to Script a MS SQL Server Table

by geoff.walter In reply to How to Script a MS SQL Se ...

I was looking for a method to generate the t/sql CREATE code based on the already-existing table(s).

Collapse -

How to Script a MS SQL Server Table

by mattohare In reply to How to Script a MS SQL Se ...

Using a COM related language such as VB or VC++, you can use the SQLDMO object to script objects. I use this as part of my documentation process.

Most of the objects in SQLDMO (tables, views, stored procedures, indexes, constraints, etc.) use sqldmo.

The method is "Script" and it even includes the GO statements and SET statements to make it work. If you like, I'll be happy to share examples from my source code.

Collapse -

How to Script a MS SQL Server Table

by geoff.walter In reply to How to Script a MS SQL Se ...

Thanks for your prompt reply and for sharing your VB code, it will be helpful.

Collapse -

How to Script a MS SQL Server Table

by geoff.walter In reply to How to Script a MS SQL Se ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums