I know how to override the language chosen, and I believe that the chosen language is driven by the tags. I'm not asking for So if a question is tagged C#, and I want to post a SQL Server stored procedure, I use the following before my code block, and the syntax highlighting obeys the language I've specified:

<!-- language: lang-sql -->

My problem is: In some cases, the chosen language is incorrect (or perhaps it is NULL). Here is a recent example:

Sorting results basing on a string variable content

You'll notice that my answer is the only one that has proper highlighting for SQL (since I've done the above), even though the question is tagged sql-server-2008-r2 and every answer contains SQL code. The solution, I assume, is to add a more generic tag (like sql) but do we really want to have to add such generic tags to all questions just to get the code editor to behave? I prefer to have questions tagged with the correct version of SQL Server, but don't think it needs to include sql, sql-server and sql-server-2008-r2 for me to know that it's a question about SQL Server 2008 R2 and to expect that the code editor will understand I'm going to answer in SQL, not REXX.


For clarification, I think that if a question is tagged sql-server* (and only that), the automatic choice for language should be SQL. Currently I believe that no language has been chosen because the algorithm looks for exact matches, and sql-server-2008-r2 has not been added to the list. Why do I believe this? I just changed the question in question to sql-server-2008 and sql-server-2008-r2, and SQL is still the selected language. Which means it must have matched on the former. So I guess my question is in two parts:

  1. can we please add both sql-server-2008-r2 and sql-server-2012 to the set of tags that selects sql as the language?
  2. can we consider (or tell me why we shouldn't) a regex matching as well, so that we don't encounter the same issue when SQL Server 2015 is released?
  • You can use language-all at the top of your post instead of language if you are going to have multiple code blocks (such as in your post) - not an answer but might help you.
    – vcsjones
    Jun 16, 2012 at 21:24
  • 1
    @vcsjones nice tip, I'll definitely remember that! But I find most users aren't aware of this aspect of code formatting in the first place, so a bigger concern for me is that either no language or the wrong language seems to have been selected in the example I cited.
    – Aaron Bertrand Staff
    Jun 16, 2012 at 21:31
  • IMO the question should be tagged with SQL, and not just to make the code highlighter happy. Jun 16, 2012 at 21:32
  • 1
    @CodeInChaos do you mean instead of sql-server-2008-r2, or in addition to? If the OP wants to specify a certain version (which is definitely helpful for those answering the questions), how is he/she to know that it should also be tagged with something generic?
    – Aaron Bertrand Staff
    Jun 16, 2012 at 21:33
  • 1
    As a test, I added the [sql] tag to the question, and the code in all the answers seems to be fixed (highlighted as SQL). Jun 16, 2012 at 21:34
  • @ypercube I know the fix, just curious why SQL isn't picked up from a tag prefixed with SQL. Especially when it's the only tag (I know the algorithm is more complex when there are multiple tags that might have inherently different language choices).
    – Aaron Bertrand Staff
    Jun 16, 2012 at 21:36
  • You are right on that (how is the OP supposed to know?) Jun 16, 2012 at 21:37
  • The answer is almost certainly going to be "the OP doesn't know, but now you do!"
    – Aaron Bertrand Staff
    Jun 16, 2012 at 21:37
  • At least [SQL] and [SQL-Server] should be there, since I assume that solutions aren't specific to that exact version of the server. I'm not familiar enough with the topic to decide with [sql-server-2008-r2] should be there too. Typically I only recommend version tags if the question is not about the current stable version of the product. Jun 16, 2012 at 21:37
  • The problem is if you only tag with SQL, you get MySQL and Oracle answers. If you only tag with sql and sql-server, you absolutely do get version-related issues. Almost always a bunch of additional dialog about what version, since many answers depend heavily on features introduced in SQL Server 2005 or SQL Server 2008.
    – Aaron Bertrand Staff
    Jun 16, 2012 at 21:39
  • @CodesInChaos for SQL Server the specific version is often very important - it's not about stability but if the user asking the question doesn't know how to solve a problem, there may be much more efficient ways to do it in a newer version, or limitations in really old versions that we need to be aware of. I would argue that aside from questions about overall architecture or concepts that are better placed on dba.SE, just about every sql-server question on SO is better and more answerable if the specific version is listed.
    – Aaron Bertrand Staff
    Aug 13, 2012 at 16:20

1 Answer 1


I fixed all of the [sql-server] type tags so that they all default to SQL-lang.

It's probably not worth it to add regex matching mechanisms or prefix matching.

  • Thanks Robert. When SQL Server 2015 goes into beta, should I re-activate this question, start a new request, or just ping you directly? :-)
    – Aaron Bertrand Staff
    Jun 17, 2012 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .