Security question

  • MSSQL 2000

    How and if I can find the LAST DATE that a USER accessed a database or the sql server? 

    Your help is appreciated.

  • I believe the only way is if you were already tracking login information. The only login information is for current connections. Once the connection is broken, SQL Server doesn't care about it any more.

    -SQLBill

  • At my current workplace I run the following proc once a minute through SQL Agent.  Not exact science but works pretty well...

    CREATE  procedure RecordDbUtilization as

    insert into DBUtilization (db) select distinct db_name(dbid) from master..sysprocesses with (nolock)

    where db_name(dbid) not in (select db from dbutilization with (nolock)) and dbid > 6

    update dbutilization set

    dateacessed = getdate(),

    host = hostname,

    NTUser = nt_username,

    login = loginame,

    app = program_name

    from master..sysprocesses with (nolock)

    where db_name(dbid) = db

    and loginame not in ('NT AUTHORITY\SYSTEM')

    GO

  • Thank you guys for your help.

    Terry, I will use your procedure. Thanks

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

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