How to Delete huge data from a SQL Server Table - SQL Server / TSQL Tutorial

In this video you will learn how to delete large number of records from a SQL Server Table. By watch this video you will learn following topics

1--How to Delete large number of records from SQL Server Table in small chunks
2--What is the difference between Full Recovery Mode and Simple Recovery Mode
3--Does Transactional Log file grow if we set the database to Simple Recovery and Delete huge number or records?
4--How to get the record count while Transactions is deleting the records by using NoLock Option
5--How to Shrink Log file and release unused space to Operating System
6- How to write script to delete records in small chunks from SQL Server Table

Script used in the video that can be used to delete data from table in small portions

--Get the Data File and Log file for a Database in MB
SELECT file_id, name, type_desc, physical_name, (size*8)/1024 SizeinMB, max_size
FROM sys.database_files ;



--Delete the Records in Small Chunks from SQL Server Table
DECLARE @DeleteRowCnt INT
SET @DeleteRowCnt = 1

DECLARE @DeleteBatchSize INT
SET @DeleteBatchSize=100000

WHILE (@DeleteRowCnt > 0)
  BEGIN

     DELETE TOP (@DeleteBatchSize) [dbo].[Customer]  
     WHERE RegionCD='NA'

  SET @DeleteRowCnt = @@ROWCOUNT;
END


How to Delete Huge Data from SQL Server Table in Small Portions

19 comments:

  1. Can we use wattpad pro apk instead of simple notepad for coding?

    ReplyDelete
  2. Is there any temperature app or algorithm to solve the issue?

    ReplyDelete
  3. Storyscape hack apk is an easy and free way to get free gems and coins in the game. You don't need to spend money on gems or coins, with the help of the Storyscape hack apk you will have unlimited gems and coins. This is the latest Storyscape hack apk that has been released and is working.

    ReplyDelete
  4. Discovery plus premium mod apk latest version is a digital game that gives you the chance to play the game with ease. Many people who have played it before have found the game to be very interesting. This can be compared to the games that are played on the internet.

    ReplyDelete
  5. Ze Whatsapp Apk Android We are glad to share this with you guys. Our team has just finished uploading ze whatsapp apk android on our repository, so you'll be able to download it right now! Our Ze Whatsapp Apk Android gives you unlimited features with no ads.

    ReplyDelete
  6. This blog is about Blackmart Pro Apk and it will give you the necessary information about this blackmart pro apk. You will also get to know about the blackmart pro apk free download and installation. If you are willing to know about the blackmart pro apk, then you are just at the right place. This blackmart pro apk will make your apk downloading easy and very fast.

    ReplyDelete
  7. You can download Ns Whatsapp Apk full version latest version and install it on your Android devices. You can also set the display picture or cover photo of your choice, can change color and transparency, add different smilies emoticons and you can add many contacts at once and send messages through whatsapp.

    ReplyDelete
  8. Grand theft auto vice city apk is this week's game for the android game lovers. I know it's an android game which are loved by many many people. Grand theft auto vice city apk is a action and adventure mobile game. its graphics is also good like other popular mobile games.

    ReplyDelete
  9. Burner app is a brand new app for android that is making waves in the webosphere. Burner app allows you to create temporary burner numbers for texting and calling. Download our Burner App and get the unlimited features.

    ReplyDelete
  10. Kinemaster prime update apk is one of the best video editing apps available in the market. It is an all-in-one video editing app that can provide you with amazing results. KineMaster is now available from our website and it has already become a popular name among the people.

    ReplyDelete
  11. The Grand Theft Auto series of video games has been around for more than 20 years, and the latest release is GTA Vice City. As with most games in the series, there are mods (modifications) that can be installed to change various aspects of the game. One such mod is the GTA Vice City Mod Apk, which allows you to play the game on your Android phone or tablet. For more Information visit us at https://gtavicecityapk.com/

    ReplyDelete
  12. Among Us Mod Apk is one of the best game I ever played. Modded version of this app has unlimited everything. You must play and enjoy.

    ReplyDelete
  13. Humidifier for dry skin
    Low humidity is very big problem for us. We always fight for dry skin specially in winter season. Humidifier is very important for our home to control humidity level and fight dry skin.
    Thanks

    ReplyDelete