I was looking for ways to speed up the script that GK53 suggested. I had someone here suggest that I use the following code to speed up my overall process:
exec sp_msforeachtable @command1="alter table ? nocheck constraint all";
exec sp_msforeachtable @command1="alter table ? disable trigger...
GK53,
For other tables that I needed to shrink, I:
[ol 1]
copied the records to retain to a temporary table (SELECT * INTO tempTable FROM ...)
truncated the original table
inserted the retained records from the temp table into the original
dropped the temp table
[/ol]
That worked...
Hi George,
The table I am trying to shrink has a trigger, many FKs pointing to it, and worse, a bunch of schema-bound views that prevent me from dropping it. I am going to try Option #2 to see how it does.
Thanks George and GK53!
Tom
GK53 -- I am not quite sure what you are suggesting. I am trying to stay away from transactions, but what you are suggesting is interesting, yet I don't see how it would speed things up and keep the log size small. The tables I have to shrink are large, have triggers and lots of FKs that...
I am working in a transactional SQL Server 2012 development environment where I am writing a script to "shrink" (remove excess records from) the large tables in backup copies of our Production database. The tables have record counts in the multi-million range. Referential is not a big issue for...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.