Scripting a table in SQL Server Management Studio does not include indexes

Peter Schmitz

Administrator
Staff member
If you ever needed to script a table in SQL Server Management Studio (SSMS), you might have noticed that simply right-clicking the table, selecting "Script table as" will not include indexes:

upload_2020-7-28_10-32-41.png


This is usually an issue, especially when you are using this script to integrate the tables into a DevOps deployment. After all, missing indexes can/will cause the environment to behave different than expected.

Luckily, there's an easy solution. In SSMS, select "Tools" -> "Options". Find "SQL Server Object Explorer" -> "Scripting" -> "Table and view options" -> "Script Indexes", and set the value to "True":
upload_2020-7-28_10-40-23.png


Now, when you script a table, the index(es) on it will automatically be scripted, too:

upload_2020-7-28_10-41-57.png
 

Attachments

  • upload_2020-7-28_10-39-6.png
    upload_2020-7-28_10-39-6.png
    53.8 KB · Views: 666
Top