|
-
Feb 1st, 2008, 05:30 PM
#1
[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 ?
-
Feb 3rd, 2008, 02:31 PM
#2
Re: SQL Server 2005 Truncate Table
Anyone ?
Please help... I still have this problem
-
Feb 3rd, 2008, 02:41 PM
#3
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
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 4th, 2008, 10:59 AM
#4
Re: SQL Server 2005 Truncate Table
This is my solution:
Code:
DELETE FROM my_table
DBCC CHECKIDENT ( my_table, RESEED, 0 )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|