This is quite similar to SEDE Sql Highlighter is borked for aliases with single quotes which was apparently fixed in 2010. Mine is slightly different. If you look at my answer to http://stackoverflow.com/questions/9507404/sql-server-2005-database-dropped-how-to-find-out-who-did-it-when-it-happened you can see a similar issue, where delimited strings are not properly interpreted, and everything after is considered part of the string.
DECLARE @FileName VARCHAR(255) SELECT @FileName = SUBSTRING(path, 0, LEN(path)-CHARINDEX('\', REVERSE(path))+1) + '\Log.trc' --' FROM sys.traces WHERE is_default = 1; SELECT TOP 1 LoginName, HostName, ApplicationName, StartTime, TextData FROM sys.fn_trace_gettable( @FileName, DEFAULT ) AS gt WHERE EventClass = 47 AND DatabaseName = 'splunge' ORDER BY StartTime DESC;
I added a comment to the end of that line with a single apostrophe to avoid the rest of the code from appearing as a string, but mods please feel free to edit my answer by removing the comment to see the difference. I assume The
'\' in the string treats the
\ as an escape character.
Not a major annoyance but the color coding is extremely useful and makes the code readable.