Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    108

    Thumbs up Unanswered: [2005] How do I script out all indexes?

    Hello,

    we are using Sql Server 2005 Managament Studio.

    Can someone tell me how I can script out all DROP/CREATE INDEXES for a particular database?

    We only want to script out the INDEXES, not the tables.

    Please advise.

    Thanks.

    `Le

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    You can try using a (free) tool I wrote, called scriptdb.exe.

    It scripts out all objects (including indexes). The script for each object is created in a separate file. It would be a simple matter to alter the tool so it only scripts the indexes (the source is available so you could do it yourself). Or you can just run it as is and script out all the objects, and throw away what you don't want if all you care about are indexes.

    You can get it here: http://www.elsasoft.org/tools.htm

    Alternatively, in SSMS, you could try using the Generate Scripts Wizard for this, but it won't do both drop and create at the same time. only drop OR create. not both.

    Hope this helps!
    Last edited by jezemine; 10-24-06 at 18:43.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    108

    Thumbs up

    Thanks for the offer, but my company has a policy against 3rd party executables.

    As for Sql Server Management Studio, I cannot seem to find anyplace to script out ONLY the indexes.

    Are there other suggestions?

    `Le

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    you appear to be right, GSW won't script the index separate from the table.

    even if you have a policy against 3rd party executables, you can still use scriptdb since I posted the source code.

    Just build it yourself using VS or csc.exe and then it's *your* executable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •