Who has accessed my 2005 server?

  • Didn't work for me. The following error when attempting to run this on 9.0.3159 in a clustered environment.

    Msg 156, Level 15, State 1, Line 14

    Incorrect syntax near the keyword 'CASE'.

  • krombit,

    I have seen this error. I get this error when I run the script in a database where the compatibility level is set to something other than SQL Server 2005. So check the compatibility level of the db you are running the query in or run the query in tempdb.

  • Very Useful script. Thanks...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • Hi

    Is there any similar script that can be used in SQl server 2000.

    Tanx 😀

  • Eswin,

    There is not a similar script for 2000 because 2000 does not have the default trace. You can create a trace in 2000 that mimics the 2005 Default Trace and then you could create a similar script that reads that trace file(s). You would need to put the Trace creation in a stored procedure and then have that sp run at startup.

  • Jack,

    I just re-discovered this script, something I used a while back and I've hit an odd snag. Last time I see I posted that when i ran it I only got info from the last/most recent trc file. I just troed thsi again and darned if I'm not still having the same issue. I did check and the DB COmpatability for my MASTER DB is 2005 and I am using a 2005 server and yet the value of T.Path is the same for all rows retruned and that is the last trc file created. I checked and there are 5 trc files and 2 of those have todays date so I'm trying to figure out why I'm still getting just the last one.

    Any thoiughts?

    I'm gonna use this for some Login auditing checkjs because it looks like this is the only way in SQL 2005 to find out login auditing data. I can't believe that by 2005 the SQL Server product didn;t have some decent auditing abilities yet.

    Thanks

    Kindest Regards,

    Just say No to Facebook!
  • If you are using the current version of the script you should be getting data from ALL the trace files. The T.path column will only return the path of the current file which is why there is a CASE statement setting up the first parameter in the call to fn_trace_gettable. T.path comes form the sys.traces table so it only has the current file name.

  • Jack Corbett (12/22/2009)


    If you are using the current version of the script you should be getting data from ALL the trace files. The T.path column will only return the path of the current file which is why there is a CASE statement setting up the first parameter in the call to fn_trace_gettable. T.path comes form the sys.traces table so it only has the current file name.

    "yeaaaahhhhhh, I'm gonna need you to come in this wekedn, yeahhhh, both Saturday & sunday, uhh,huuu"

    Right now I am figuratively banging my head and yelling "Idiot!" at myself.

    Thanks. SOmetims its hard to see the data for the rows & columns

    Kindest Regards,

    Just say No to Facebook!
  • The script is very useful. I know it was designed for SQL 2005, however it also seems to work on SQL 2008. I have tried it on several SQL 2008 servers successfully, but I am getting an error on one of them and I'm not sure exactly why. SQL Server would be running on a Windows 2008 R2 Virtual Server. Here is the error:

    Server: Msg 567, Level 16, State 7, Line 1

    File 'S:\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MSSQL10.trc' either does not exist or is not a recognizable trace file. Or there was an error opening the file.

    This is definitely a valid file on the server. I am able to open it directly with SQL Profiler, but not using the script from a query window in SSMS.

    Thanks!

  • Hi,

    I do not like "NULL" value in results.

    May I suggest this :

    ...

    CASE

    when S.type_desc is NULL then 'allowed via a Windows Group'

    else S.type_desc

    end as type_desc,

    ...

    🙂

  • charlesd (4/2/2013)


    The script is very useful. I know it was designed for SQL 2005, however it also seems to work on SQL 2008. I have tried it on several SQL 2008 servers successfully, but I am getting an error on one of them and I'm not sure exactly why. SQL Server would be running on a Windows 2008 R2 Virtual Server. Here is the error:

    Server: Msg 567, Level 16, State 7, Line 1

    File 'S:\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MSSQL10.trc' either does not exist or is not a recognizable trace file. Or there was an error opening the file.

    This is definitely a valid file on the server. I am able to open it directly with SQL Profiler, but not using the script from a query window in SSMS.

    Thanks!

    Charles,

    Sorry for the delayed reply. This version of the script actually doesn't work on 2008 R2 because MS changed the path to the trace file a bit so the CASE that creates the path doesn't work correctly. Here's what you need to change for R2:

    sys.fn_trace_gettable(CASE WHEN PATINDEX('%Log[_]%', path)<> 0

    THEN LEFT(path, PATINDEX('%Log[_]%', path) + 2) +

    '.trc'

    ELSE T.[path]

    END, T.max_files)

  • marie contencin (4/4/2013)


    Hi,

    I do not like "NULL" value in results.

    May I suggest this :

    ...

    CASE

    when S.type_desc is NULL then 'allowed via a Windows Group'

    else S.type_desc

    end as type_desc,

    ...

    🙂

    Marie,

    That's a nice little add, if you don't like the NULL's.

  • Thanks for those suggestions, but I am getting a syntax error when I try to run them. Could you please send me the entire script with the change.

    Thanks

  • Jack Corbett (4/9/2013)


    charlesd (4/2/2013)


    The script is very useful. I know it was designed for SQL 2005, however it also seems to work on SQL 2008. I have tried it on several SQL 2008 servers successfully, but I am getting an error on one of them and I'm not sure exactly why. SQL Server would be running on a Windows 2008 R2 Virtual Server. Here is the error:

    Server: Msg 567, Level 16, State 7, Line 1

    File 'S:\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MSSQL10.trc' either does not exist or is not a recognizable trace file. Or there was an error opening the file.

    This is definitely a valid file on the server. I am able to open it directly with SQL Profiler, but not using the script from a query window in SSMS.

    Thanks!

    Charles,

    Sorry for the delayed reply. This version of the script actually doesn't work on 2008 R2 because MS changed the path to the trace file a bit so the CASE that creates the path doesn't work correctly. Here's what you need to change for R2:

    sys.fn_trace_gettable(CASE WHEN PATINDEX('%Log[_]%', path)<> 0

    THEN LEFT(path, PATINDEX('%Log[_]%', path) + 2) +

    '.trc'

    ELSE T.[path]

    END, T.max_files)

    jack

    Did you update the actual script as well for R2 or did you just make the changes in the posting?

    Kindest Regards,

    Just say No to Facebook!
  • I found the error and was able to get the script to run on SQL Server 2008 R2. I needed to change every occurrence of 'path' to 'T.[path]'.

    Thanks!

Viewing 15 posts - 16 through 30 (of 31 total)

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