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.



more ▼

asked Oct 09, 2012 at 07:15 AM in Default

avatar image

30 5 6 10

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Oct 09, 2012 at 07:31 AM

avatar image

Kev Riley ♦♦
66.8k 48 65 81

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?


Oct 09, 2012 at 08:19 AM heryhe
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 09, 2012 at 07:15 AM

Seen: 455 times

Last Updated: Oct 09, 2012 at 08:20 AM

Copyright 2018 Redgate Software. Privacy Policy