Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vdavid70
Yak Posting Veteran
67 Posts |
Posted - 2005-12-19 : 11:49:02
|
| This probably very basic but i have not written a line of code in a long while. When you are trying to delete rows in a table within a database and it has foreign key that references another table in the same database. What is the best thing to do in order to acheive the delete.for example this is the code i wrote DELETE t_faultFROM t_fault INNER JOIN t_fault_history ON t_fault.t_fault_id = t_fault_history.t_fault_idand t_fault.EST_RESOLUTION_DATE between '2002-05-22 11:31:42.000'and '2005-06-30 18:36:24.000' and i get this error messageServer: Msg 547, Level 16, State 1, Line 1DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_T_Fault_History_T_Fault'. The conflict occurred in database 'faults', table 'T_Fault_History', column 'T_FAULT_ID'.The statement has been terminated. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-12-19 : 12:07:12
|
| depends on your business. You'll either need to first delete any fault history for the faults you want to delete, or maybe:implement a logical deleted column (bit or datetime) which you would need to honor in your other SPs to ignore the deleted faults when appropriate. But that way you can still maintain your history.Be One with the OptimizerTG |
 |
|
|
|
|
|