Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Speed Up Stored Procedure sql server 2005 express

Posted on 2010-11-11
5
Medium Priority
?
521 Views
Last Modified: 2012-05-10
sql server 2005 express  

I have a stored procedure that I would like to speed up in someway.

I'm using the "like"  operator...


Is there another way the same results but faster... ?


Thanks
fordraiders

USE [DescMatchGisXref]
GO
/****** Object:  StoredProcedure [dbo].[get_View_SAP_Data_Grid1]    Script Date: 11/11/2010 11:25:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_View_SAP_Data_Grid1]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[get_View_SAP_Data_Grid1] @param3 nvarchar(100)  
AS	
SELECT     dbo.SapData.MFRNUM, dbo.SapData.MFRNAME, dbo.SapData.WWGDESC, dbo.SapData.ITEM, dbo.SapData.XREF, dbo.SapData.SPIN, 
dbo.SapData.REDBOOKNUM, dbo.SapData.WWGMFRNAME, dbo.SapData.WWGMFRNUM, WwgExtra.dbo.SapAltData.ALT1, 
WwgExtra.dbo.SapAltData.ALT1SPIN, dbo.SapData.RICHTEXT, dbo.SapData.COMMENTS, WwgExtra.dbo.SapAltData.ALT1DESC, 
WwgExtra.dbo.SapAltData.ALT1DESC2, WwgExtra.dbo.WwgExtra.GREEN, WwgExtra.dbo.WwgExtra.SEGMENT, 
WwgExtra.dbo.WwgExtra.PRIVATE_LABEL
FROM dbo.SapData INNER JOIN
WwgExtra.dbo.WwgExtra ON dbo.SapData.ITEM = WwgExtra.dbo.WwgExtra.ITEM INNER JOIN
WwgExtra.dbo.SapAltData ON WwgExtra.dbo.WwgExtra.ITEM = WwgExtra.dbo.SapAltData.ITEM
WHERE SapData.MFRNUM LIKE '''' + @param3 + ''%''

Open in new window

0
Comment
Question by:Fordraiders
  • 2
  • 2
5 Comments
 
LVL 11

Assisted Solution

by:David Kroll
David Kroll earned 1000 total points
ID: 34113878
I'd put (nolock) after each table name

FROM dbo.SapData (nolock) INNER JOIN
WwgExtra.dbo.WwgExtra (nolock)

Also make sure that you have indexes on the fields that you are joining the tables on (SapData.ITEM and SalAltData.ITEM).  Also put an index on SapData.MFRNUM.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 total points
ID: 34113901
the problem here is the like operator,the only way to improve the like operation here is to have full text indexing on that column, and modify your query accordingly. but it can add some overhead to the system
0
 
LVL 3

Author Comment

by:Fordraiders
ID: 34115045
WHAT DOES "nolock"  DO never seen that before ?
0
 
LVL 11

Expert Comment

by:David Kroll
ID: 34115055
0
 
LVL 3

Author Closing Comment

by:Fordraiders
ID: 34133612
Thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Screencast - Getting to Know the Pipeline

972 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