March 14, 2012 at 9:38 pm
Jeff Moden (3/14/2012)
terryshamir (3/14/2012)
For me its a bug, the guys who worked with it saw nothing wrong with it.
Tell those guys I agree. If you learn to use it to your advantage, it will no longer be a "bug" for you. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
March 22, 2012 at 2:55 am
Jeff I'll pass on your reagrds to them.
I think the National lottery computer uses the same functionality many into one 😉
I've learnt quite abit form this forum, long may it continue..
March 23, 2012 at 7:08 am
From the OP:
>>But it just picks the last one.
Jeff kinda touched on this, but I wanted to reiterate something: there is NO ordering in set based processing unless you EXPLICITLY STATE IT. SQL Server doesn't give you "the last one". It gives you ANY one. If there are 3 values it could be first, middle or last and it isn't guaranteed to be repeatable either. And another common misconception is that if there is a clustered index on a table you will always get rows out in the clustered order.
I have fixed many, MANY flaws at clients over the years because of this incorrect assumption.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
March 23, 2012 at 8:29 am
I think Celko view point is from ANSI specs and Relational Model Theory and with that in mind he's right.
It's a major failure to overload the most essential language keywords.
The Jeff arguments stats the specs are that from the MS SQL Server and that behaviour is a feature.
While to know the theory is essential and is good to know the ansi specs (as others DBMS) my DB is not running in a ansi DBMS, in fact in a ansi compliant enviroment my app ill stop to run and it make me wonder if the ansi specs are years behind the real world needs and it is the main cause of the lack of portability between the products sold by the main vendors.
Now to back to the OP question.
It's how it works!
I prefer to use SET unless I need to set many variables from the same row and I can ever consider to return only a single row using PK or a aggregate.
I hate when these erros pop up but I'm most pissed with hiden logic errors.
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply