Skip to main content

Get size of all tables in database


SELECT
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB,
    SUM(a.used_pages) * 8 AS UsedSpaceKB,
 (SUM(a.total_pages) - SUM(a.used_pages)) * 8   AS UnusedSpaceKB,
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 /1024 AS UnusedSpaceMB
FROM
    sys.tables t
INNER JOIN    
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN
    sys.schemas s ON t.schema_id = s.schema_id
WHERE
    t.NAME NOT LIKE 'dt%'
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255
GROUP BY
    t.Name, s.Name, p.Rows
ORDER BY
    t.Name

Comments

Popular posts from this blog

Copy All tables with Data in Another Database

CREATEPROCEDURE [dbo].[uspCreateCopyTables]-- GOALTEST,GOAL   -- parameters for the stored procedure here      @toDatabase VARCHAR(100)        ,@fromDatabase VARCHAR(100)    ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from  SET NOCOUNT ON;    DECLARE @fullTableList VARCHAR(8000);    DECLARE @idx

SignalR Examples

ChatHUBS.cs 

Code publicvoid Send(string name, string message) {  // Call the broadcastMessage method to update clients.    Clients.All.broadcastMessage(name, message);  }  Startup.cs

publicvoid Configuration(IAppBuilder app)  {  // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888    app.MapSignalR();  }  Htmlpage

<!DOCTYPE html>

Resignation Letter Format

[Director Name] Director [Company Address]
Dear Sir


Due to some unavoidable circumstances on personal reasons, I hereby tender my resignation to the post of [Post] with effect from [effect date]. I shall be serving a Notice Period of [notice days] days. My last working day would be [Last working date]. After serving for almost 1 year, I have gained immensely from the knowledge and experience. I must admit that I take lot of good things from here, which should take me too much higher levels. 

It was fantastic working with [company Name]  and I take this opportunity to thank my colleagues. The associations I've made during my employment here will truly be memorable for years to come.

I request the authorities kindly to accept my resignation with effect from [Last working date] Thank you very much for the opportunity to work here.

Sincerely,



Ashish Kumar Srivastava Sr. Software Engineer