Listare tabele fara clustered index

Configurare noua (How To)

Situatie

Mai jos este o procedura ce aduce toate tabelele fara clustered index de pe o baza de date MSSQL Server.

Solutie

create procedure ListHeapTables

as

SELECT [Table] = s.[Name] + N'.' + t.[Name] 
FROM [sys].tables t
   INNER JOIN [sys].schemas s 
 ON t.[schema_id] = s.[schema_id]
WHERE NOT EXISTS
(
   SELECT 1 FROM [sys].indexes i
   WHERE i.[object_id] = t.[object_id]
   AND i.index_id = 1
)

Tip solutie

Permanent

Voteaza

(1 din 3 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?