March 17, 2008 at 2:40 pm
I know how to create a structure of a table from another table without copying data but how do you create a structure of a table with all constraints from another table?
To Create NEW Table structure without copying data but no constraints:
Select * into New.Table from Old.Table where 1 =2
Want to know how do you create a table structure from another table with all constraints?
Any answer would be appreciated.
Thanks
March 17, 2008 at 2:45 pm
In Management Studio, right-click the table name, click Script Table as -> CREATE to -> New Query Editor window.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 17, 2008 at 2:45 pm
In SSMS you can right-click the table and and use script as create and it includes all the contraints, indexes, etc...
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 17, 2008 at 2:47 pm
Thanks for the quick reply.
March 17, 2008 at 2:48 pm
GSquared (3/17/2008)
In Management Studio, right-click the table name, click Script Table as -> CREATE to -> New Query Editor window.
Darn, you beat me by seconds!:crying:
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 17, 2008 at 2:56 pm
Jack Corbett (3/17/2008)
In SSMS you can right-click the table and and use script as create and it includes all the contraints, indexes, etc...
Actually, it doesn't include indexes (except the primary key and/or clustered index). You have to script those separately.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 17, 2008 at 3:02 pm
I don't have sql on my laptop so I could not look and I haven't done that in a while.
You could also right click on the database - all tasks - generate scripts and just select the table you want and include the indexes.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 17, 2008 at 3:44 pm
Actually you can click on Tool --> --> options --> scripting. From here you can set the default to script does not exists, script indexes, foreign keys etc....
Then when you right-click script to you will have everything 😉
March 18, 2008 at 8:16 am
Adam Haines (3/17/2008)
Actually you can click on Tool --> --> options --> scripting. From here you can set the default to script does not exists, script indexes, foreign keys etc....Then when you right-click script to you will have everything 😉
Cool. I didn't know that option existed.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 18, 2008 at 8:19 am
Yeah. I just found out about it a few weeks ago :). It has the equivalent options to Tasks --> generate scripts.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply