Server: Msg 547, Level 16, State 1, Line 6 
Author Message
 Server: Msg 547, Level 16, State 1, Line 6

I have a simple table -
CREATE TABLE [dbo].[Table1]
(
        [ID] [char] (27) COLLATE
)GO

The column ID is defined as a foreign key in other table.
When I try to delete a record from this table, I get the
normal sql error- Server: Msg 547, Level 16, State 1, Line

The problem is that I want to capture this error, but

this error?




        DELETE [Table1]
        WHERE




                BEGIN  

                                print 2 -- ID IS IN USE
                END

Thanks
Shipra.



Wed, 13 Oct 2004 03:09:30 GMT
 Server: Msg 547, Level 16, State 1, Line 6

error trapping in sqlserver is extremely weak. also, there are some *fatal*
errors when encountered they will terminate the entire batch. hence, your
error trap statement will never get called.

in any case, here is a slight rewrite that might trap other non-fatal errors




DELETE [Table1]
WHERE





    print 'no rows deleted.'

    print 'id in use.'

--
-oj

http://www.rac4sql.com


Quote:
> I have a simple table -
> CREATE TABLE [dbo].[Table1]
> (
> [ID] [char] (27) COLLATE
> )GO

> The column ID is defined as a foreign key in other table.
> When I try to delete a record from this table, I get the
> normal sql error- Server: Msg 547, Level 16, State 1, Line

> The problem is that I want to capture this error, but

> this error?




> DELETE [Table1]
> WHERE




> BEGIN

> print 2 -- ID IS IN USE
> END

> Thanks
> Shipra.



Wed, 13 Oct 2004 03:26:35 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Server: Msg 7399, Level 16, State 1, Line 1 error on .mdb as linked server

2. Server: Msg 7399, Level 16, State 1, Line 1 error on .mdb as linked server

3. Server: Msg 7619, Level 16, State 1, Line 2

4. Server: Msg 214, Level 16, State 2, Procedure sp_execute, Line 52

5. Server: Msg 8114, Level 16, State 1, Procedure co_AddTrader_Information, Line 0

6. Server: Msg 7399, Level 16, State 1, Line 1

7. Server: Msg 4425, Level 16, State 1, Line 1

8. Select error:Server: Msg 8120, Level 16, State 1, Line 1

9. Server: Msg 7411, Level 16, State 1, Line 1

10. Server: Msg 1701, Level 16, State 2, Line 2

11. Server: Msg 7391, Level 16, State 1, Line 4

12. Server: Msg 1776, Level 16, State 1, Line 1


 
Powered by phpBB® Forum Software