question

rsheik avatar image
rsheik asked

SP_Helptext for Table Script

Hi, I want view the create script for a table(which is already created) as below create table my_table ( col1 varchar(10), col2 varchar(10), . . . ) I am using **sp_helptext** and it is working for only Views and Stored_Procs. I need similar functionality for view Table Script (with Indexes) Thankx
scripttables
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
This web site runs based on your votes. Please indicate all the helpful answers below by clicking on the thumbs up next to them. If any one answer lead to a solution, please indicate this by clicking on the check mark next to that answer.
0 Likes 0 ·
@SQLShark avatar image
@SQLShark answered
Hi there, You can do this using SSMS: Object Explorer>Database>Table>Right Click>Script table as >Create to....
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rsheik avatar image rsheik commented ·
That I know. I want to automate through a Script..
0 Likes 0 ·
iainrobertson avatar image
iainrobertson answered
There are lots and lots of examples of this available online already. Try a google search for "generate create table script sql server". Result #2 is pretty good. If you get stuck implementing any of the suggestions I'm happy to help out.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

erlokeshsharma08 avatar image
erlokeshsharma08 answered
Right click on database --> Tasks ---> generate scripts ---> select all the tables you want plus some very useful options such as data, keys ....boom
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

arislapson avatar image
arislapson answered
you can do: exec sp_help table-name
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.