Bhuvnesh (6/2/2010)
elutin (6/2/2010)
As promised, another version. It contains much more code, but it's probably the fastest way to do what you require:
...
,@Product = Name
OPTION (MAXDOP 1)
...
Do we need here (maxdop 1 ) ?
Yes, it is a "must have" one. In case of parallel processing the state of variables cannot be guaranteed.
The full explanation of method can be found in http://www.sqlservercentral.com/articles/T-SQL/68467/ nice article by Jeff Moden.