![sql express profiler sql express profiler](https://4.bp.blogspot.com/-AS9WRejeBv0/UefccFNCg2I/AAAAAAAAAaU/OcUyCwKz7fE/s1600/image.png)
Use block (/* */) comments wherever possible in production code, particularly if the comment occurs within part of a query.Here’s what you see in Profiler when you run it: (If you don’t see it, this query aliases the fulltext_catalog_id column as data_space_id, and returns 4 columns in the result set.) SELECTįulltext_catalog_id-, name, path, is_default, is_accent_sensitivity_on,ĭata_space_id, file_id, principal_id, is_importing The really dangerous thing is that if you inspect the erroneous-looking query closely, you’ll find that it is a different, yet syntactically valid, query. If you had only seen the query in Profiler and didn’t know what the original query was, do you know which query was actually executed? If I shrink the Profiler window (both to demonstrate the problem, and so screenshots nicely fit onto this page) and run the query, the statement appears like this: This query selects a single column from sys.fulltext_catalogs, while the other columns are commented out. Not only that, but the syntax highlighting is applied after the word-wrapping takes place, which exacerbates the problem.įulltext_catalog_id-, name, path, is_default, is_accent_sensitivity_on, data_space_id, file_id, principal_id, is_importing While that might seem okay at first glance, the fact is that artificially introducing extra newlines when the statement syntax depends on the arrangement of newlines… can lead to interesting things. The problem is that Profiler word-wraps captured SQL statements according to its window size.
![sql express profiler sql express profiler](https://images0.cnblogs.com/blog/622439/201411/061716326422395.png)
Whether you realized it or not is a separate question entirely. If you’ve worked with SQL Server Profiler for any length of time, there is a decent chance you’ve come across this issue already. Well, obviously not, or this post wouldn’t need to exist.Īside from the obvious differences, there’s a particular issue with single-line comments that’s indirect and somewhat subtle, yet it can be significant. When I first mentioned that developers should try to move away from using single-line comments (using –) and towards block comments (using /* */) in T-SQL, it was understandable that I got a bunch of “ummm… what?” looks.
![sql express profiler sql express profiler](https://image.slidesharecdn.com/perfmonandprofiler201-091009081434-phpapp02/95/perfmon-and-profiler-201-9-728.jpg)
(While I can’t take credit for finding this issue originally - I heard about it several months ago - for the life of me I can’t remember or find where it was mentioned, so if you know of a reference, please leave a comment.)