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

26 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
  14. Sonic Forces Mod Apk
    is one of the best game you will must enjoy this moded version of this game and it has all characters unlocked.

    ReplyDelete
  15. https://pdfhour.com/ is my favourite site to download or read online books.

    ReplyDelete
  16. Apple Music Modified is a great music app for Android. It has a lot of features that you can't find in other music apps. With the mod apk, you can get access to all the features of the app for free. The app has a great design and it's easy to use. You can also create your own playlists and share them with your friends.

    ReplyDelete
  17. Pato Player is an app that allows you to watch live football games on your Android device. The app has a user-friendly interface and provides HD quality streaming. You can also chat with other fans while watching the game. For more Info visit us at https://apkspike.com/pato-player-apk/

    ReplyDelete
  18. Are you looking for a bus driving game that will test your skills to the limit? If so, then you need to try out Bus Simulator Ultimate Free Download. This game is a real challenge, and it features a wide variety of buses that you can drive. There are also plenty of different settings to choose from, so you can always find a new challenge. However, if you feel like you need more of a challenge, then you can try out the mod apk.

    ReplyDelete
  19. HorrorField Modded is a new and popular horror-themed mod apk for Android that allows players to experience the horror genre in a way that has never been possible before. Through its innovative features, this app allows users to interact with the game world in ways that were never possible before, as well as giving them an unparalleled level of control over their experience. With horrorFile, you can explore horrifying locations, experience unique death scenes and much more.

    ReplyDelete