x

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
more ▼

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

heryhe gravatar image

heryhe
30 5 6 8

(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

Kev Riley gravatar image

Kev Riley ♦♦
52.8k 47 49 76

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
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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

SQL Server Central

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

Topics:

x62

asked: Oct 09, 2012 at 07:15 AM

Seen: 331 times

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