-
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
the following.
UPDATE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_DepartmentNo'.
The conflict occurred in database 'Assets', table 'DepartmentMaster', column
'DepartmentNumber'.
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
key violation".
Help will be appriciated.
The same applies to a Primary key violation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks