How To Find DB Size

  • Hi All

    In a SP how i can find the DB size. Is there any system SP for this purpose?

    Regards

    Qaiser

  • Check out the below link.  I'm not sure if their is or not a system sproc...If it's not listed in sql books online (i'm sure you checked) their probably isn't.  The article basically is creating it's own sproc that will get the size of db using dbcc commands.

  • Hi John

    Where is link? I think you forget to paste the link.

    Regards

    Qaiser Javed

  • Try the sp_helpdb, sp_helpfile and sp_spaceused system SPs.

  • Also try sp_databases

  • sp_helpdb could be better when compared with sp_databases

    since if database size is more than 2 TB then sp_databases could have

    some problems.

  • Sorry I can't find the link i was googling it and can't remember my search criteria.  Anyways the answer is as stated before by others is using sp_helpdb or sp_databases. 

    If you want to have a stored procedure that returns the specific size then you can create your own sproc that that will return your own result sets. 

    Maybe you can use the INSERT ... EXECUTE command? Something like this:

    CREATE TABLE #temp1 (....)

    CREATE TABLE #temp2 (....)

    INSERT #temp1 (column list)

    EXECUTE sp_helpdb

    INSERT #temp2 (column list)

    EXECUTE sp_databases

    SELECT columns you like to see

    FROM #temp1

    JOIN #temp2

    ON your joine criteria

    WHERE some optional extra filters

     

    hope this helps...

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply