#temp tables and index ?

  • How do I put  indexes on an temp table

    CREATE TABLE #temp (Branch VARCHAR(5),

    StockCode VARCHAR(5), QTY NUMERIC(14,4))

    If I wish indexes on the Branch and stockcode fields, how ?

    I need to speed up searching on these temp tables in a query I am running .

     

     

  • You can create indexes on a temp table as you would on a 'normal' table.

    In your situation, try:

    create clustered index CI__temp on #temp (Branch, StockCode)

    You could also define a primary key or create a non-clustered index instead.

    Please read up on 'create index' in BOL for more information.

Viewing 2 posts - 1 through 2 (of 2 total)

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