Saturday, February 25, 2012

Capturing SQL noise word exception...

Hi All,

I have a requirement where I need to find the list of noise words from a set of words in a SP.

PS: Too common words are said to be noise words and SQL maintains list of noise words on its own.

Say I have a sentence like "I am a software engineer. Here I need to get the list of noise words (I, am, a).I have written a logic where I will split the sentence into words and process word by word. I will first take one word and I have a select statement which will throw SQL noise word error exception if it is noise word.

Logic is
1. Take a word from the sentence.
2. Write a select statement like "select * from job where contains (jobdescription,' extracted word')"
3. If the word is noise word then SQL will throw a noise word exception.
4. I try to capture this error and based on that I have some logic.
5. If noise error thrown (I am using @.@.error)
do this;
do this;
else
do this;
do this;
6. Now my problem is, when the SQL throws noise exception, the execution of the SP stops immediately and the rest of the logic is not executed.
7. But some how I need to capture the exception and continue with the program flow.

I have different logic where I can achieve my requirements. (Instead of capturing SQL exception, maintain the noise words in a table and check with the table). but my question is there any way where I can capture the SQL exception and continue the program flow?

Please reply to my mail id.

TIA,
Varada.Can we do this 1 problem at a time?

Are you looking for a word in a string?

Look up CHARINDEX

No comments:

Post a Comment