How to get the Foreign key violation in a procedure
I have a problem.
This is in SQL Server 7.0.
Whenever a foreign key violation occurs, we get the standard message like
UPDATE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_DepartmentNo'.
The conflict occurred in database 'Assets', table 'DepartmentMaster', column
The statement has been terminated.
How to trap this error in a Stored procedure or in a trigger?.
We can track it using @@Error variable.
But when the key violation occurs SQL Server not even goes into
The update trigger code.
Also, if I have multiple forign key columns and how do I know that
which column is failed?. The error number is 547 for all columns of "Foreign
Help will be appriciated.
The same applies to a Primary key violation.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL