Solved

SQL Server stored procedure

Posted on 2011-09-07
3
204 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
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Stored Proc - Performance Enhancement 15 58
Stored Proc - Rewrite 42 61
TSQL convert date to string 4 37
Select question from MySQL 1 13
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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.

821 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