.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Content Database Size in SharePoint

Posted By:Jean Paul       Posted Date: July 17, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we have explored How to find content database size in SharePoint
 

In this article we can explore, how to find the content database size - manually & programmatically.

Server Object Model

In the SharePoint Server Object Model, there is SPWebApplication.ContentDatabases property to fetch the databases within web application.

For the database, we can use the DiskSizeRequired property to find the size.   This property actually represents the database backup need size.

Code

Following is the code which performs the following:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace ContentDatabaseSize
{
    class Program
    {
        static void Main(string[] args)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPWebApplication webApplication = SPWebApplication.Lookup(new Uri("http://hp"));
                if (webApplication != null)
                {
                    foreach (SPContentDatabase cd in webApplication.ContentDatabases)
                        Console.WriteLine(cd.DisplayName + " " + cd.DiskSizeRequired);
                }
            });

            Console.ReadKey(false);
        }
    }
}

clip_image001

The size divided by 1024 * 1024 gives size in MB.  It is around 60 MB.

Verification with Database

You can go to SQL Server Management Studio to verify the database size. Select Properties menu item for the database.

clip_image002

Please see the property Size as shown below.

clip_image004

Summary

In this article we have explored How to find content database size.


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend