How to get the spatial index in CREATE TO script?

Posted on

Question :

Is it possible to get the spatial index using the create to script using SQL Server 2012?

When I write out a table using SCRIPT TABLE AS > CREATE TO in Microsoft SQL Server Management Studio 2012, I get the primary key index, but the spatial index does not carry over.

Thank you!

Answer :

The spatial index, as with other objects, have their own script <object> as menus and need to be done separately. This can be done to the clipboard and pasted to the query window generated by the script table as command.

I can’t confirm at the moment, but I suspect that the primary key and other constraints come out in the script table as options since the are an integral part of the table definition, whereas indexes are not.

The generate and publish scripts wizard can also be used, but it is a lot of steps if you are just doing a few items.
Technet, How to: Generate a Script

Leave a Reply

Your email address will not be published.