If you are getting this error,
SQL Server is satisfying any of below conditions:
- You can’t use TRUNCATE TABLE where the tables are referenced by a foreign key constraint
- You can’t use TRUNCATE TABLE where the tables participate in an indexed view.
- You can’t use TRUNCATE TABLE where the tables participate in transactional replication
- You can’t use TRUNCATE TABLE where the tables participate in merge replication.
Work around: Use the DELETE statement in place of TRUNCATE TABLE. because its not advisable to remove replication , CDC or index views.
You can refer: Difference between Truncate and Delete
Note: If none of conditions are matching "TRUNCATE TABLE" will reset your identity column to a default value of 1
No comments:
Post a Comment