How to use SQL server foreach loop in SQL scripts?
You can use SQL server foreach loop in T-SQL against a set of data in T-SQL.SQL server foreach loop is set to keep looping as long as there is at least a row of data in @Enumerator. PowerShell is still viable and potentially a lot easier, especially when you leverage dbatools. You can use Get-DbaDatabase to not only…
Answered Aug 23, 2021 · 1.8K Views Read answer →