Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Issue after copying data
Message
 
 
To
30/11/2010 14:01:50
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01491153
Message ID:
01491159
Views:
56
>Yeah, but that complains when I have FK constraints set.

Take a look at this blog post

Delete all data in all tables in a database when you have foreign keys

From comment by Denis Gobo to this blog post:
-- disable referential integrity
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' 
GO 

EXEC sp_MSForEachTable 'TRUNCATE TABLE ?' 
GO 

-- enable referential integrity again 
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' 
GO 
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform