views:

47

answers:

1

Hi,

Fairly simple question, but I don't see it anywhere else on SO:

Do indexes (indices?) on a temporary table get automatically deleted with the temporary table?

I'd imagine they do but I don't really know how to check to make sure.

Thanks,

Phil

+1  A: 

Yes they get dropped along with the table. It is not possible for an index to exist independently of its table.

In terms of checking this for yourself you could do

SELECT OBJECT_NAME(OBJECT_ID), * FROM tempdb.sys.indexes

before and after running your DROP temp table.

Martin Smith