January 13, 2016 at 2:28 pm
hello,
have to delete records from a table SELECT * FROM [DB_NAME].[dbo].[Table_Name].Insert_Datetime (Column)
there are million of records, please help me what is best possible way to delete them?
January 13, 2016 at 4:30 pm
An oldie but goodie: Deleting Large Number of Rows[/url]. Note the SQL 2005 code is compatible with all newer versions of SQL Server.
The technique in the article will delete rows in batches as small as needed to allow other queries access to the table in between operations so you do not affect performance of the database too greatly while deleting the data.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 13, 2016 at 10:31 pm
Use Truncate table deletes all the rows in that table
TRUNCATE TABLE LargeTable
GO
January 13, 2016 at 10:54 pm
LOL
January 14, 2016 at 1:27 am
A third option is to drop and recreate the table.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 14, 2016 at 2:22 am
johnwalker10 (1/13/2016)
Use Truncate table deletes all the rows in that table
TRUNCATE TABLE LargeTable
GO
True, but it will be useful if you have simple recovery model for your db.
and put a CHECKPOINT after every delete query (which should happen in loop) to truncate the log
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply