Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get stats on table but without views
Message
De
04/08/2011 08:29:35
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Titre:
Get stats on table but without views
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01520153
Message ID:
01520153
Vues:
79
I have this script which gets some stats on tables but I need a small modification in it so it will not include the Views.
DECLARE @Message varchar(400)
DECLARE @SQL VARCHAR(MAX)

BEGIN TRY

if object_ID('TempDB..#Stats') is not null
   drop table #Stats

CREATE TABLE #Stats (TableName sysname, ROWS BIGINT, reserved VARCHAR(100), DATA VARCHAR(100), 
 index_size VARCHAR(100), unused VARCHAR(100))

SELECT @SQL = COALESCE(@SQL,'') + '
 insert into #Stats execute sp_spaceused ' + QUOTENAME(Table_Name,'''') 
 FROM INFORMATION_SCHEMA.TABLES
EXECUTE (@SQL)
SELECT * FROM #Stats ORDER BY TableName

END TRY
BEGIN CATCH
   SET @Message=ERROR_MESSAGE()
   ...
END CATCH
Anyone would know what to adjust in that SQL so it will not take views?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform