3

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.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Mar 7, 2017 at 14:36
0

1 Answer 1

4

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.

Options

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.

Generate Scripts

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.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
answered Mar 7, 2017 at 14:43
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.