I need script related to databases

  • Can any one help me here....

    I need a script to find out the users and last usage of the database.

    Here i know the query to get the details after restart of sqlserver.But i dont want this.

    I need the last usage date and list of users on all databases in a instance before the restart of sqlserver?

    Please help me...

    Thanks in Advance....

    GLNP

  • As far as I know the serve doesn't store this information. You could have a trigger on LOGON, that will writes the login name, date and database name each time that someone logs on.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • i love logon traces, but for tracking/ accessing specific databases, i don't think it would work;, a logon trigger occurs before a user connects to a database...so in the trigger you wouldn't find a database reference;

    you'd want to use a server side trace for DML i htink instead, so you can track/roll up info from the trace results.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

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