Get code for building Indexes?

  • I want to get a complete copy (with indexes) of a very large table to a new temp table in the fastest manner possible.

    I can use the "select ....into " commands to create the basic table with the data, but without the indexes, and I want to create the indexes after the temp table is created.

    How can I get a copy of the sql code (using TSQL) used to build the indexes of the initial table so that I can use it to build the indexes on the temp table?

    using SQL Server 2000

    Thanks for any and all help.

  • Open Query Analyzer with your database open click on the index in the object browser and click on create and you will generate the create index statement you need.  Hope this helps.

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

  • I am aware of that method of getting the code to build the indexes.

    I need a way within TSQL to get the indexes.

     

    to rephrase: what sql code would I run to get the code to build the indexes?

    Thanks again.

  • Hello,

    Have a look at the following sproc:  master.dbo.sp_helpindex

    The code in that sproc should point you in the right direction as to what you need to do to get at the index metadata.

    Good Luck!

    jg

     

  • Perfect!  With that stored procedure I should be able to accomplish what I want.  Thanks for pointing me in the right direction.

     

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply