• shnizzle (8/29/2008)


    Hugo, I read the KB article and even when taking it into account, I think that my code is correct - it looks exactly as the statement described in the 'Workaround' section, sans the 'ORDER BY'.

    Hi Shnizzle,

    Personally, I don't consider this article as implying that it SHOULD work, and that it ALWAYS WILL work. And I value very much the fact that the syntax "SELECT @var = @var + SomeColumn FROM ..." is not mentioned in Books Online at all very telling.

    If you still want to implement this and put it in production, feel free to do so ... but never forget that it IS undocumented, so you'll have to retest after every service pack, every patch, and every hardware update and still be prepared to be surprised. The fact that many users do use this and do rely on this does not guarantee that Microsoft won't change it - just remember what happened to GROUP BY without ORDERY BY when upgrading from SQL 6.5 to SQL 7.0, or to views with TOP 100 PERCENT and ORDER BY when upgrading to SQL 2000 to SQL 2005. For my production code, I'll stick to officially documented code. 🙂


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/