Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 key violation

Author  Topic 

Ask SQLTeam Question

0 Posts

Posted - 2003-01-08 : 08:57:44
Laurence writes "We have an application that queries a SQL 2000 (SP1) database. In general the application runs well, but occasionally a query is run that causes a Foreign Key violation.

I have tried using Profiler to capture these by adding Errors and Warnings fields to the Events and filtering for Error Equals 547. However this only captures an entry noting the error occurred, not the SQL that caused it. I know the name of the table affected, and that the query is an INSERT, but there are too many inserts to the table happening (that work) to capture
them all and scan them manually.

Any answer to the above much appreciated.



12543 Posts

Posted - 2003-01-08 : 10:25:34
You can log the sql statements and errors to a table using the profiler then search for the error.
You might find this slows things down a lot though.

If the insert is done via a stored proc (and not errored in a trigger) then you could log info from the SP.
One of the reasons for using SPs for all database access.

Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

- Advertisement -