How to copy indexes from one table to another in SQL Server

后端 未结 6 2246
北海茫月
北海茫月 2020-12-15 05:38

I need to copy the indexes from one table to another. There are a LOT of indexes and I don\'t want to recreate them from scratch. Seems error prone anyways.

I have c

6条回答
  •  长情又很酷
    2020-12-15 06:24

    Do you want to copy the Index definition?

    Then you can reverse engineer the index, triggers etc using the "Script" option in the Microsoft SQL Management tool

    Simply right click on a table name in the SQL Management Studio table list and select "Script Table as" and then "Create to"

    You can't copy the Index data as it relates to the physical storage of the Index

    First check that you have "Tools/Options/SQL Server Object Explorer/Scripting/Script Indexes" set to "True". This is set to false in some version of the SQL Management tool (thanks Mark)

    enter image description here

提交回复
热议问题