Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stored procedure select statement error

Status
Not open for further replies.

pokemonjohn

Programmer
Jul 3, 2002
3
GB
Hello.
I have a stored procedure that returns a recordset to an ASP page. What want to add is some error handling, as if people enter a character ( *, ^, % etc...) it causes an error. All i want to do is, if an error is caused it to return no results. so i could add an extra section of code which is only run when an error occurs but how do i get this to run. i have tried if @@error <> 0 but could not get it to work
this is my code so far.

CREATE PROCEDURE SP_ImagebankRes
(
@SchParam varchar(600),
@SchPict varchar(100)
)
AS
declare @sql varchar(1024) --local var for sql string

set @sql = 'SELECT [KEY],RANK,imageID,imagename, txtdescription,Metkeyword,
metsystamatic,MetSubjectArea,MetType,PictURL, PictFileURL
FROM CONTAINSTABLE(imagebankmeta1,*,'''+ @SchParam + ''') C
JOIN imagebankmeta1 P
ON P.imageID = C.[KEY]
where rank > 5
'+ @SchPict +'
ORDER BY RANK DESC'

exec(@sql)

GO


Thankyou for your help.
 
I would do this in the asp page that calls the stored procedure... It has perfect functions for spotting these characters and it saves you serverload.
 
Thanks.
was just wondering if there was another way of doing this.
 
There might,
I'm not such an sql wizard myself,
but I would try to keep all that sort of actions away from my database server...

For performance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top