>>I don't know much about sqlserver (yet), but have you tried option 1 here
>>
>>1. "Disable" parameter sniffing by using local DECLARE'd variables that
>>you SET equal to the parameters inside the stored proc, and use the local
>>variables instead of the offending parameters in the queries. This is the
>>solution that you found yourself. SQL can't use parameter sniffing in
>>this case so it must make some guesses, but in this case the guess based
>>on average column density is better than the plan based on a specific but
>>"wrong" parameter value (NULL).
>>>>
http://groups.google.com/group/microsoft.public.sqlserver.server/browse_thread/thread/2c5c8472bff7dea0/ad37d8aec76e2b8f?lnk=st&q=#ad37d8aec76e2b8f>
>Thanks for the link but I cannot use this approach.
Then, would this work - in fox like code which you'll have to translate
lparameters p1
local p2
p2 = p1 && maybe + '' or any other function so it cannot 'know' in advance what will be in p2
select ..... where (Name like m.p2)
Gregory