Please can some one help me to get a list of indexes on a temporary table that I've created in SQL Server 2012
CREATE TABLE #tmpTable (ID BIGINT PRIMARY KEY, INDEXCOLUMN BIGINT)
IF NOT EXISTS(SELECT * FROM tempdb.sys.indexes WHERE name = 'IX_TMPINDEX' AND OBJECT_ID = object_id('tempdb..#tmpTable'))
BEGIN
CREATE NONCLUSTERED INDEX IX_TMPINDEX ON #tmpTable (INDEXCOLUMN)
END
GO
SELECT * FROM tempdb.sys.indexes WHERE OBJECT_ID = object_id('tempdb..#tmpTable')
Here's one way, using sp_helpindex:
CREATE TABLE #temp (id int, val1 int)
CREATE INDEX ix_t1 on #temp (id)
EXEC tempdb.dbo.sp_helpindex '#temp'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With