We have a stored procedure which is running for ever, whereas when it is run as script it takes just couple of minutes to complete. When I just declare the params and assign values to them and run the script it's done in couple of mins. There is no application that is consuming the result set,it's a DW proc.
I tried couple of things:
- I tried to flush the plan for that procedure and run again but didn't run.
- I tried to run the SP with recompile but didn't run.
What can be the possible reasons that it runs as plain script and not as SP even after flushing the cache for that SP?