Personal tools
You are here: Home SQL Server How To's Size of user tables on SQL database
Navigation
Log in


Forgot your password?
 
Document Actions

Size of user tables on SQL database

procedure returns the size of every user tables for one specific database

This procedure returns the size of every user tables for one specific database, you just need to execute the procedure with the database name, if no database be specified , it will take the database selected on the checkbox


Procedure:

IF OBJECT_ID('GetAlltblRowsSize') IS NOT NULL DROP PROC GetAlltblRowsSize
GO
CREATE PROCEDURE GetAlltblRowsSize (
 @dbname sysname = null
)
AS
 DECLARE @execstr nvarchar(255)
 SET NOCOUNT ON
 IF @dbname IS NULL SELECT @dbname = DB_NAME()
 SELECT @execstr = 'EXEC ' + @dbname + '..sp_MSforeachtable @command1="sp_spaceused ''?''"'
 EXEC(@execstr)

GO



To execute the procedure:

EXEC GetAlltblRowsSize 'teste'


Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls