Solved

Sql server error number is the same for "Forignkey" And "check Constraint"

Posted on 2008-06-22
3
686 Views
Last Modified: 2009-12-16
Hello
am little confused , i know that errors in sql server has  A number code ,  but the problem is
the error Number is same in Foriegn Key Violation and in  conflicted with the CHECK constraint
both of them has the same error Number  547
so when i try to violate the foringn key constraint it comes with the error as following
Msg 547, Level 16, State 0
also when i try to confilct with check constraint i recieve the same error number
Msg 547, Level 16, State 0

My problem is these number is important for me because i use it form my vb.net app. to  handle the error and raise an friendly error message to the user
1-Can you help me and tell me why is this happen ?
2-Can you give me a link to all SQL server Errors numbers/code because i searched and i didnt find
0
Comment
Question by:ali_alannah
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21840204
>1-Can you help me and tell me why is this happen ?
 foreign key IS a check contraint.

>2-Can you give me a link to all SQL server Errors numbers/code because i searched and i didnt find
http://www.microsoft.com/technet/support/ee/ee_advanced.aspx

or, in sql server, you have the table sysmessages:
http://technet.microsoft.com/en-us/library/ms177546.aspx
0
 

Author Comment

by:ali_alannah
ID: 21841960
Hello angelIII:
You post very helpfull but Please guide me and tell mh if i want to diffretiate between Forigkn key violation and the Check constraint confilct , to raise a friendly error message to the user
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21842001
to differentiate, you have to check the error text/description.
which is "dangerous", as if ever the language setting of the login is changed, the text might change also.

now, with due respect:
is your project that advanced/complete that you have to "bother" such subtle differences in what exactly the user is reported as error message?
especially foreign key constraints should "never" be violated by a application, given the user only those choices that cannot violate the foreign key constraints ...
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question