Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get stats on table but without views
Message
 
À
04/08/2011 08:29:35
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01520153
Message ID:
01520154
Vues:
50
This message has been marked as the solution to the initial question of the thread.
>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?
....
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE <> 'View'
...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform