Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. DECLARE @current VARCHAR(500);
  2. DECLARE @start VARCHAR(500);
  3. DECLARE @indx INT;
  4.  
  5. SELECT
  6. @current = path
  7. FROM
  8. sys.traces
  9. WHERE
  10. is_default = 1;
  11.  
  12. SET @current = REVERSE(@current)
  13. SELECT @indx = PATINDEX('%\%', @current)
  14. SET @current = REVERSE(@current)
  15. SET @start = LEFT(@current, LEN(@current) - @indx) + '\log.trc';
  16. SELECT
  17. CASE EventClass
  18. WHEN 46 THEN 'Object:Created'
  19. WHEN 47 THEN 'Object:Deleted'
  20. WHEN 164 THEN 'Object:Altered'
  21. END,
  22. DatabaseName,
  23. ObjectName,
  24. HostName,
  25. ApplicationName,
  26. LoginName,
  27. StartTime
  28. FROM::fn_trace_gettable(@start, DEFAULT)
  29. WHERE
  30. EventClass IN (46,47,164) AND EventSubclass = 0 AND DatabaseID <> 2
  31. ORDER BY
  32. StartTime DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement