[RESOLVED] SQL Server 2005 Truncate Table
On my server at home, I get this error when I try to truncate a table:
Cannot truncate table 'dbo.*****' because it is being referenced by a FOREIGN KEY constraint.
Yes, it is referenced with a foreign key, but there is no data in the other table ! so there is nothing to complain about !
I have simmilar table structure at on the servers at work, and when I do that it does not complain...
There must be a setting somewhere to make it check if there are actually records in the other table, but where ?
Re: SQL Server 2005 Truncate Table
Anyone ?
Please help... I still have this problem
Re: SQL Server 2005 Truncate Table
That is just ANSI SQL. If the table has a referenced child table and the FK is in place you can not issue a trucate table command. You can remove the FKs truncate and replace if you want. You might be able to diable the FKs then re-enable when completed
Re: SQL Server 2005 Truncate Table
This is my solution:
Code:
DELETE FROM my_table
DBCC CHECKIDENT ( my_table, RESEED, 0 )