Computing.Net > Forums > Programming > Constraint Violated Error in SQL

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Constraint Violated Error in SQL

Reply to Message Icon

Name: mdelato
Date: February 1, 2006 at 00:51:16 Pacific
OS: Win 2003 Server
CPU/Ram: 3GHz,512 RAM
Comment:

Hi there. We're doing a save on a MS Great Plains with SQL Server screen and get the following error:
"A save operation on table 'WS_Time_Sheet_TRX_WORK' failed because a database constraint was violated."

If I hit More Info it says:
[Microsoft][ODBC SQL Server Driver][SQL Server]INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_WS10702_UPR00100'. The conflict occurred in database 'NSP', table 'U00100PR', column 'EMPLOYID'.

I know these messages probably make perfect sense to you guys, but I'm a newbie. Can you point me in the right direction? My thinking is that maybe I should force the foreign key constraint using the "WITH NOCHECK" option or maybe the wrong data type is mapped between the two tables sharing the Foreign Key and the key should be deleted and recreated.

Any help you can provide would be most appreciated! Assume that I'm a newbie and that I know very little. You won't hurt my feelings if you "dumb it down" so I can understand where to begin! lol I'm not even entirely sure I know where to look to edit the connection in the first place.



Sponsored Link
Ads by Google

Response Number 1
Name: jhunt303
Date: February 1, 2006 at 02:15:57 Pacific
Reply:

"FOREIGN KEY constraint"

looks like you may have a duplicate entry in your key field


0

Response Number 2
Name: jhunt303
Date: February 1, 2006 at 02:24:19 Pacific
Reply:

Off the SQL site:

A foreign key constraint allows certain fields in one table to refer to fields in another table. This type of constraint is useful if you have two tables, one of which has partial information, details on which can be sought from another table with a matching entry. A foreign key constraint in this case will prevent the deletion of an entry from the table with detailed information if there is an entry in the table with partial information that matches it.


0

Response Number 3
Name: mdelato
Date: February 1, 2006 at 07:45:25 Pacific
Reply:

Thanks guys. This kind of info from another source is helpful. Kind of like getting a second opinion from a doctor. :-)

But how do I make a fix or make a change to the database relationship? where do I go to view and edit the SQL? Enterprise Manager?


0

Response Number 4
Name: Krispy
Date: February 1, 2006 at 23:48:00 Pacific
Reply:

It looks like you are trying to insert an EMPLOYID value into the table UPR00100, which requires a similar EMPLOYID value to already exist in the WS10702 table. (Foreign Key constraint)

You can view the Index/Relationships through Enterprise Manager. Expand the NPS database, select 'Tables', right-click the UPR00100 table and select 'Design Table'. Now right-click the Design form and select 'Indexes/Keys'


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Constraint Violated Error in SQL

remove a decimal or round up in sql www.computing.net/answers/programming/remove-a-decimal-or-round-up-in-sql/1390.html

Duplicate rows in SQL Joins www.computing.net/answers/programming/duplicate-rows-in-sql-joins/12430.html

Logical error in Modul www.computing.net/answers/programming/logical-error-in-modul/6174.html