• Thanks for the reply Matt,

    I just want to return 1 if the last statement( which will be one of the statements in else-if block) is executed successfully but it returns -1 on success. Is it because of the use of variables @messagelist or @pos...?

    As i have mentioned in my post earlier, I had a similar problem before in another SP which i overcame by removing all such variables(don't know why). It returns -1 on success no matter what is returned from the SP.

    There is one more thing, if instead of returning any value, a print statement E.G. print 'success' is given, then it works fine.........please help....