February 6, 2026 at 3:01 am
I need to delete rows from both the temporal main and history tables.
The temporal main table can get deleted without issues.
For the temporal history tables, I code to turn system versioning off, issue the Delete, then turn system versioning back on.
If I execute manually each of the below cmds one at a time, they all work without an error.
But if I execute the whole 3-line unit of code, it errors.
I have hundreds of temporal history tables to delete so I cannot be executing the cmds one at a time...
Appreciate your attention and help.

February 6, 2026 at 3:15 am
Serializing made no difference... Manual run of each cmd takes sub-seconds...

February 6, 2026 at 8:40 am
Try putting 'GO' after each statement.
ALTER ...
GO
DELETE...
GO
February 6, 2026 at 9:10 am
scroll down to "Use custom cleanup script approach"
February 6, 2026 at 2:36 pm
This works. I will have to take the dynamic sql approach as coded on the article. Thank you very much!
February 6, 2026 at 2:38 pm
I am coding an sproc so I cannot code many GOs. Thanks for helping!
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply