Exception Handling in stored procedures for sql server 2000

  • My variable holds an integer value like

    @StudentID as int

    While entering a value for the stored proc if the user enters a varchar value

    then that exception should be got.

    Can anyone help me to solve this problem.

     

     

  • If I understood your question correctly.

    You have a stored procedure that expects an integer input argument.

    The user executes this stored procedure and passes in a varchar value instead, and you want to catch the data exception inside the proc.

    As far as I know, since SQL Server converts data types char/int implicitely, if there're any data type exceptions, it would be caught by the server already, before it even get to your proc.

    For example:

    exec procA 1 -- procA would receives an integer 1

    exec procA '1' -- procA would receives an integer 1

    exec procA 'a' -- SQL Server exception would occurs

  • Thank yoy Mr.Thang Hoa


    ng for posting ur reply for my question.

    It will be of very great use to me.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply