Hi,
I have a UDF that does most of the joins and when I run it, it read about 100-150 pages (from sql profiler) but if I wrap this UDF in sp then the sp will do the read about 243287 pages.
Furthermore, the UDF itself performs index seek but the sp performs index scan on one of the searched columns.
Can anyone please advise?