Results 1 to 2 of 2

Thread: capturing Data type mismatch error

  1. #1
    Join Date
    May 2003
    Location
    India
    Posts
    15

    capturing Data type mismatch error

    Hi All,
    Create Table tb_mismatch
    (x int)
    Create Procedure proc_mismatch
    as
    begin
    insert into tb_mismatch values('s')
    if @@error<>0
    begin
    print ' entered error loop'
    end
    print 'successfully exited'
    end
    Now, when i try to capture the above error its not getting trapped..its directly going to the final end statement.
    I have even tried calling subprocedures so that it comes out of the inner procedure and by some means i can move forward in the outer proc,but even that helped out..
    The proc. is able to capture all the other errors like primary key voilation,binary data truncated but not the datatype mismatch error (mainly int with varchar...)
    any ideas are greatly appreciated.
    Thanks & regards,
    Pavan.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Some errors are not captured by @@error, that is a flaw in T-SQL. MS has corrected that in SQL 2005.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •