question

heryhe avatar image
heryhe asked

Is there a function or Stored procedure can be called if we use create & drop index user interface in MSSQL

Hi All, Current case that I have now, is creating hundreds of indexes in five databases. I already have the name of tables, columns and indexes. What I don't want here to do is create the indexes one by one manually. Is there a function or stored procedure can be called to generate create and drop index script? Your help will be very appreciated. Thanks, Hery
index
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
No, but you can write one. Put the data about tables, columns and indexes into a table and then use a query over that to generate the create index sql statements - copy and paste the output into another query window and run! Alternatively execute the statement as dynamic sql from within the proc, but I would prefer to see the output first, just to give a sanity check.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

heryhe avatar image heryhe commented ·
Hi Riley, Thanks for your prompt reply. That's good idea, but is there an interactive tool that I can use to generate index from particular table and column? Hery
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.