November 23, 2010 at 1:30 am
I was considering locking/blocking and availability of the table
November 23, 2010 at 2:11 am
Paul White NZ (11/22/2010)
Since this is in the SQL Server 2008 forum, you could also use bulk-logged INSERT...SELECT then ALTER TABLE...SWITCH.
I thought SWITCH only worked in Enterprise Edition?
If you have to reindex a large table then make sure you have enough space in TEMPDB.
If you can't use switch purging then try something like
SET ROWCOUNT 50000
WHILE 1=1
BEGIN
DELETE FROM yourschema.yourtable WHERE <your criteria>
OPTION (MAXDOP=1)
IF @@ROWCOUNT = 0
BREAK
END
SET ROWCOUNT 0
If you are doing a significant delete then I'd plan to do it after a full back up and in a quiet time on the server if such a period exists.
If there is any danger that you might need to get the records back in a hurry then I'd BCP them out and store them with the CREATE TABLE script so you have the archive and what the archive actually was at the time it was taken.
If you take the approach suggested by Jeff then it may be faster but it does mean that you are temporarily going to need enough space for your original records AND the new copy prior to the purge.
It sounds as if you need to plan a regular purge/archive job for this table so you can automate this for future use.
November 23, 2010 at 2:21 am
David.Poole (11/23/2010)
I thought SWITCH only worked in Enterprise Edition?
One can only create partitioned tables on Enterprise, it's true, but ALTER TABLE...SWITCH works regardless of any partitioning.
All tables are partitioned (they have one partition at least).
ALTER TABLE...SWITCH is a very fast way to switch a whole table to another.
December 4, 2010 at 11:46 am
Paul White NZ (11/23/2010)
David.Poole (11/23/2010)
I thought SWITCH only worked in Enterprise Edition?One can only create partitioned tables on Enterprise, it's true, but ALTER TABLE...SWITCH works regardless of any partitioning.
All tables are partitioned (they have one partition at least).
ALTER TABLE...SWITCH is a very fast way to switch a whole table to another.
I swear I saw somewhere where you used SWITCH to move rows you wanted to delete from a larger table to a non-partioned table. If you have a link for that, I sure would appreciate it. Thanks, Paul.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 4, 2010 at 11:58 am
Ah... never mind. The thing I was looking for is in the link you previously posted and it doesn't do quite what I thought. What I thought was that there was a way to use SWITCH to move only the rows we wanted to delete to a non-paritioned table and then drop that table.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply