New answers tagged

1

Add a T-SQL TRY/CATCH block so that the loop doesn't continue indefinately following an error. Invoke-SqlCmd buffers SQL Server error messages so you won't see errors until the PowerShell script completes. USE [DB]; SET XACT_ABORT ON; SET NOCOUNT ON; DECLARE @cnt BIGINT, @msg VARCHAR(100); SET @cnt = 1; SET @msg = ''; BEGIN TRY WHILE EXISTS ...


1

These did not work for me: exit Exit-PSHostProcess One that worked is: [Environment]::Exit(0)


Top 50 recent answers are included