TSQL variable

  • Hugo Kornelis (8/29/2008)

    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 ORDER 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. 🙂

    Ok, Hugo, I get what you are saying about officially documented code. That is a good rule to follow.

  • I'm not sure whether to be confused or intrigued. Good QOD.

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • Well, I am confused.

    Whatever happened to the concept that you cannot assign a result set to a scalar -- Should this not be barfed out at compile time in the first place ? I certainly would prefer

    it be so, in case I make an error while coding something like this, rather than have this bizarre and not necessarily predictable behavior.

    If I remember previous versions, it used to be that way.

    But even when doing this for a string instead of an integer, it still results in a long string which concatenates all of the values.

    Regards

  • I reckon it's a good example of bad practice just because the outcome isn't defined 🙂

  • (with apology)

    and i reckon, good programming skills are needed to understand this code.

    Tariq
    master your setup, master yourself.
    http://mssqlsolutions.blogspot.com

  • I take your point about it being good exercise for the mind - quite so. But in the real world, if you rely on the database behaving in a particular way when that behaviour is not defined, aren't you asking for trouble? I wouldn't want code like that in a database I'm responsible for!

    After all, for each new release MS will test that the database conforms to their definition of correct (hopefully from the documentation, or at least the same source as the documentation)!), not the way it used to work.

Viewing 6 posts - 16 through 20 (of 20 total)

You must be logged in to reply to this topic. Login to reply