Run the script in a db to get size of each table in the db.
Works on : SQL 2K5,SQL 2K8
sawmeonline,
2010-12-14 (first published: 2010-11-30)
Run the script in a db to get size of each table in the db.
Works on : SQL 2K5,SQL 2K8
DECLARE @tableName VARCHAR(1000); CREATE TABLE #AllTables ( row_num INT IDENTITY(1, 1), table_name VARCHAR(1000) ); --Using temp table, i dont like to use cursors INSERT INTO #AllTables (table_name) SELECT [name] FROM sys.Tables WHERE [schema_id] = 1 --Only dbo tables ; CREATE TABLE #TempTable ( tableName VARCHAR(100), [rows] VARCHAR(100), reserved VARCHAR(50), data VARCHAR(50), index_size VARCHAR(50), unused VARCHAR(50) ) DECLARE @i INT = 1; DECLARE @tableCount INT = (SELECT COUNT(1) FROM #AllTables ); --Loop to get all tables WHILE ( @i <= @tableCount ) BEGIN SELECT @tableName = table_name FROM #AllTables WHERE row_num = @i; --Dump the results of the sp_spaceused query to the temp table INSERT #TempTable EXEC sp_spaceused @tableName; SET @i = @i + 1; END; --Select all records so we can use the reults SELECT * FROM #TempTable ORDER BY data DESC; --Final cleanup! DROP TABLE #TempTable DROP TABLE #Alltables;
If your database is marked suspect, this will show you a step-by-step guide in how to fix the problem.
2007-09-22 (first published: 2004-03-31)
58,842 reads
The second part of Steve Jones's series on having SQL Server automatically report information to a DBA.
2003-12-25
13,017 reads
So you've created a diagram that you now need to transfer to a different server or database. This article will show give you a step-by-step guide on how to do this.
2003-11-13
11,576 reads
When transferring a database to a new server, you are bound to experience a user problem. In this article by Neil Boyle, he shows you how to transfer passwords and accounts seamlessly to a new server.
2007-10-02 (first published: 2002-08-14)
24,376 reads
An interesting feature added to SQL Server 7.0 and 2000 is the ability to purge
an error log through a stored procedure or DBCC command. In this article, Brian Knight shows some of the undocumented stored procedures to detect, read and purge an SQL Server error log in T-SQL.
2001-06-27
14,697 reads