Is that database is used by users or no?

  • Hello,
    I have to check my all instances and hosted databases to catch unused databases then set them to offline.

    I have only one idea - sql audit to catch reads on specific database.

    Maybe there is better solution for that scenario?

  • some ideas discussed here https://www.mssqltips.com/sqlservertip/3171/identify-sql-server-databases-that-are-no-longer-in-use/

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • thank you, very good article.

  • Another mechanism would be to capture logins using Extended Events. Also, you can capture calls against the database using Extended Events.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • ture, but only for  >= 2012 instances 🙂 thank you

  • kucyk - Friday, February 17, 2017 7:20 AM

    ture, but only for  >= 2012 instances 🙂 thank you

    You are posting in the 2014 forum.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • kucyk - Friday, February 17, 2017 7:20 AM

    ture, but only for  >= 2012 instances 🙂 thank you

    Extended events existed in 2008 as well:
    https://technet.microsoft.com/en-us/library/dd822788(v=sql.100).aspx

    there is just no nice GUI for it.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • The following data management view will give aggregated read / write stats at the file level.
    SELECT * FROM sys.dm_io_virtual_file_stats(DB_ID(N'AdventureWorks2012'), 2);

    The dm_db_index_usage_stats view provides even more detail like last accessed dates at the object level.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

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

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