November 27, 2009 at 10:20 am
Carlo Romagnano (11/27/2009)
Rob Goddard (11/27/2009)
does the optimizer spot this and skip all the variable assignments and just do the last one?All the variable assignments are done.
I spose this makes sense given the quick method of building a csv from a column i.e. it's clearly possibly that a single variable declaration from a select which returns multiple rows can make use of information from every row.
For the optimiser to spot that it was being assigned to a single variable AND that it would only require data from one row to create the necessary value, it would have to be an exceedingly clever piece of logic.
-- Kev
-------------------------------Oh no!
December 2, 2009 at 11:45 pm
nice one! its strange!
Thanks,
Ashka Modi
Software Engineer || credEcard Technologies (india) Pvt. Ltd.
December 11, 2009 at 10:35 pm
He I got this one ...
January 30, 2010 at 7:01 am
It would have been a good idea to reference http://msdn.microsoft.com/en-us/library/ms187330.aspx as well as the coalesce page, because people thinking that if no value is returned the value is set to null is a pretty common error. I must have explained a few dozen times over the years that
select @a = iValue from @vals where iKey <> iValue
and
set @a = (select iValue from @vals where iKey <> iValue)
behave completely differently when the filter passes no rows.
Tom
August 20, 2013 at 2:04 am
good tricky question
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 5 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy