3

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!

  • Right click on the index and create to for it – MickyT Nov 25 '14 at 17:44
  • @MickyT Oh yeah I guess that will work ok - I can append that into the first create to script and it seems to work just fine! You can add that as answer if you want... Thank you!!! – DPSSpatial Nov 25 '14 at 17:47
2

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

  • Yes, PK constraints get scripted with the table, and @MickyT is right that spatial (and clustered and secondary) indexes have to be scripted separately. Just expand Indexes under the table, and "Script Index as" normally. – Eliot Gillum Jun 25 '18 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.