How can i fix execution plan of stored procedure or user defined function in SQL Server 2005

I have SQL Server 2005. I want to know how can i fix and change execution plan of stored procedure or user defined function?

Also, want to know, if already I fix excution plan, when automatically it gets changed, and what to do to avoid it.

I have stored procedure, which run several times in an hour (lets say 500-800 times in an hour), i have observered that execution plan gets changed frequently. So, if i can fix execution plan, than i can take maximum advantage of indexes i created.
ferikAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
to change the execution plan, you'll need to either change the query OR include query and/or join hints.  You can also use plan guides

post your procedure code.
0
ferikAuthor Commented:
I have attached procedure code. basically this procedure works like notification to different application to find out further steps require to take or not.

Please advice.

Proc.txt
0
chapmandewCommented:
Are there indexes on the LCode, BID,SID and stID fields?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ferikAuthor Commented:
Yes, there are indexes on all those fields. Please note that all indexes are seperate. No index has more than 1 column.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.