locked
Need Query for checking memory used in sql server ? RRS feed

  • Question

  • User-806611011 posted

    hi guys,

    i Need Query for checking memory used in SQL Server (used size, log file size, total size used,  ?

    please guys.

    thanks. :D

    Tuesday, December 29, 2015 4:10 PM

Answers

All replies

  • User2103319870 posted

    bertanyadong

    (used size, log file size, total size used,  ?

    If you just need the Database Size and Logfile size then you can use the below query

    SELECT DB_NAME(database_id) AS DatabaseName,
    Name AS Logical_Name,
    Physical_Name, (size*8)/1024 SizeMB
    FROM sys.master_files
    WHERE DB_NAME(database_id) = 'AdventureWorks2008R2' -- Change the DB Name as per your design
    GO

    Source URL : http://blog.sqlauthority.com/2010/02/08/sql-server-find-the-size-of-database-file-find-the-size-of-log-file/

    If you need more details then check the script provided in below link

    http://blogs.msdn.com/b/sqlsakthi/archive/2011/02/28/t-sql-script-to-monitor-memory-usage-by-sql-server-instance.aspx

    PS: Try these script first in your local machine

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 29, 2015 4:45 PM
  • User1578460427 posted

    Display Data and Log Space Information for a Database

    The following SQL query returns information about the size of the database and the log files:

    USE YOUR_DATABASE_NAME_HERE;
    GO
    SELECT file_id, name, type_desc, physical_name, size, max_size
    FROM sys.database_files ;
    GO

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 29, 2015 5:00 PM
  • User-806611011 posted

    Hi a2h thank you for the answer..

    after i insert so many data,  the result size is never change to new size why ?? do you have another query for check the size of database ?

    SELECT DB_NAME(database_id) AS DatabaseName,
    Name AS Logical_Name,
    Physical_Name, (size*8)/1024 SizeMB
    FROM sys.master_files
    WHERE DB_NAME(database_id) = 'AdventureWorks2008R2' -- Change the DB Name as per your design
    GO
    

    Wednesday, December 30, 2015 7:41 AM
  • User1578460427 posted

    Another query for checking the size of the database.

    USE [YOUR_DATABASE_NAME_HERE]
    GO
    EXEC sp_spaceused
    GO
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 30, 2015 11:23 AM