Solved

Speed Up Stored Procedure sql server 2005 express

Posted on 2010-11-11
5
512 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
[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
  • 2
5 Comments
 
LVL 11

Assisted Solution

by:David Kroll
David Kroll earned 250 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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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