Is there a command that will completely clone the schema of a table? This would include all constraints, foreign keys, and indices on the table.
In SSMS the Script Table as | Create To menu command does not include indices defined on the table.
1 Answer 1
To change the behavior of Script Table As, use Tools | Options | SQL Server Object Explorer | Scripting | Table and view options as Scott Hodgin originally suggested in a comment.
Alternatively, if you want to script out multiple objects at the same time, you want to use the Generate Scripts functionality. Right click on the database in question, select Tasks --> Generate Scripts. Then the wizard will walk you through further options. You can even have it script out the data.
You can select all objects of a type, or specific objects to be scripted. By default, some parts of the database aren't scripted, including some things you might expect - like statistics contents.
Explore related questions
See similar questions with these tags.