truncate error | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

truncate error

after run this code i got a error. Is there a other way:
Server: Msg 4712, Level 16, State 1, Line 14
Cannot truncate table ‘Patienten’ because it is being referenced by a FOREIGN KEY constraint." alter table NEVENWERKINGEN NOCHECK CONSTRAINT FK_NEVENWERKINGEN_MEDICATIE
alter table WAARSCHUWINGEN NOCHECK CONSTRAINT FK_WAARSCHUWINGEN_MEDICATIE
alter table SYMPTOMEN NOCHECK CONSTRAINT FK_SYMPTOMEN_MEDICATIE
alter table SYMPTOMEN NOCHECK CONSTRAINT FK_SYMPTOMEN_SYMPTOOMOMSCHRIJVING
alter table MEDICATIEREGELS NOCHECK CONSTRAINT FK_MEDICATIEREGELS_MEDICATIE
alter table PATIENTEN NOCHECK CONSTRAINT FK_PATIENTEN_GEMEENTEN
alter table MEDICATIEREGELS NOCHECK CONSTRAINT FK_MEDICATIEREGELS_PATIENTEN
alter table MEDICATIEREGELS NOCHECK CONSTRAINT FK_MEDICATIEREGELS_EENHEDEN
alter table PATIENTEN NOCHECK CONSTRAINT FK_PATIENTEN_AFDELINGEN_PCZ
alter table DOKTERS NOCHECK CONSTRAINT FK_DOKTERS_AFDELINGEN_PCZ truncate table Patienten;
truncate table Medicatie;
truncate table MedicatieRegels;
truncate table Eenheden;
truncate table Nevenwerkingen;
truncate table Symptomen;
truncate table SymptoomOmschrijving;
truncate table Waarschuwingen;
truncate table Afdelingen_PCZ;
truncate table Dokters;
truncate table gemeenten;
When a table has Foreing Key, any operation have to do in cascade. Delete for example.
I gess truncate is similar any other operation with FK.
Refer to BOL for documentation.
Luis Martin …Thus mathematics may be defined as the subject in which we never know what we are talking about, nor whether what we are saying is true.
Bertrand Russell
True, instead use DELETE from tablename. _________
Satya SKJ
Moderator
SQL-Server-Performance.Com

]]>