Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
amurark
Yak Posting Veteran
55 Posts |
Posted - 2012-12-26 : 10:10:02
|
hi allPls tell me how to copy one table from another with its constrints structureI triedSelect * into table2 from table1but it don't copy constraints , indexes, triggers etc.Pls tell me how to do itAnkita |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-12-26 : 11:37:40
|
You can't do that, SELECT INTO only copies structure and data types. To get everything, it'd be better to create the table first, anyway. You can go in to Object Explorer, right-click on table1, then choose SCRIPT TABLE AS ---> Create.Then just change then name to table2 before you run the script. You may need to go in to tools\options\ SQL Server Object Explorer\ Scripting to make sure that all the objects you want get scripted.JimEveryday I learn something that somebody else already knew |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-26 : 23:03:16
|
quote: Originally posted by amurark hi allPls tell me how to copy one table from another with its constrints structureI triedSelect * into table2 from table1but it don't copy constraints , indexes, triggers etc.Pls tell me how to do itAnkita
generate scripts using wizard accessed from tasks-> generate scripts and you can select what all properties you want to script out.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|