?
Solved

SQL Server stored procedure

Posted on 2011-09-07
3
Medium Priority
?
224 Views
Last Modified: 2012-08-14
Hi experts,
Iam enclosing two strored procedure , the reason i would like to know whether
1. these stored procedure can be optimised for better results
2in case there is scope of improvement please suggest any necessary changes.
As i would be putting them into production.
thanks in advance.
Script-1.sql
Script-2.sql
0
Comment
Question by:Sandeepiii
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 1500 total points
ID: 36500649
In from clause more tables are used. This will make caresian product. Consider using JOINs instead such as INNER JOIN, LEFT OUTER JOIN based on your needs.

In where clause in is used to verify one value. Use like operator instead.

Order by will slow your performance.

Select all required fields and place it in a table variable. Then apply order by on the table variable. This will improve performance much.

In second script, cursor is used. Avoid that. Instead try to use CTE (Common table expresson). That will improve the performance.

Most importantly, verify whether the tables to be searched have clustured indexes. If not try to create it. That will increase select operation faster.

I sum up important points. Please google the topics that I highlighted and apply in your sp.


 
0
 

Author Comment

by:Sandeepiii
ID: 36500823
Thanks ,any particular reason to use Like operator here.
0
 

Author Closing Comment

by:Sandeepiii
ID: 36535123
It was helpful.
0

Featured Post

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question