Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to script out tables by hand

Status
Not open for further replies.

sqlcasey

Programmer
Sep 21, 2006
150
US
Hi,

Here's my question. How do I script out the CREATE syntax for a table, NOT using Management Studio. That is, I would like a SQL method of scripting the table out, much like what is provided by the "sp_helptext" function for scripting out stored procedures and triggers. The output would look like:

CREATE TABLE myTable ... etc

Does anyone know how to do this. Obviously, there is a way, because you can do it using the interface. But not sure how using only SQL commands.

Any help greatly appreciated!!

Thanks
 
You'll need to get your column info from the information_schema.columns view (or sys.columns in SQL 2005).

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top