Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get stats on table but without views
Message
From
04/08/2011 08:29:35
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Title:
Get stats on table but without views
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01520153
Message ID:
01520153
Views:
80
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
Next
Reply
Map
View

Click here to load this message in the networking platform