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

Click here to load this message in the networking platform