When I execute the following SQL command from within the Query Analyzer it takes one second to return 84 rows:
SELECT * FROM LOANS WHERE SHORT_NAME LIKE 'BYRNE%'
When I execute this same command through a stored procedure from within the Query Analyzer it takes 1 1/2 minutes to return the same 84 rows. Can someone help me understand why this happens and what I can do to speed up my stored procedure? Thanks in advance for your help.
QUERY ANALYZER COMMAND:
sp_GetLoansName byrne
STORED PROCEDURE:
CREATE PROCEDURE sp_GetLoansName
@ShortName varchar(20)
as
select * from loans where short_name like left(@ShortName,len(@shortname)) + '%'
SELECT * FROM LOANS WHERE SHORT_NAME LIKE 'BYRNE%'
When I execute this same command through a stored procedure from within the Query Analyzer it takes 1 1/2 minutes to return the same 84 rows. Can someone help me understand why this happens and what I can do to speed up my stored procedure? Thanks in advance for your help.
QUERY ANALYZER COMMAND:
sp_GetLoansName byrne
STORED PROCEDURE:
CREATE PROCEDURE sp_GetLoansName
@ShortName varchar(20)
as
select * from loans where short_name like left(@ShortName,len(@shortname)) + '%'