StopInstances.sql 554 B

12345678910111213141516
  1. CREATE PROCEDURE [dbo].[StopInstances]
  2. @serverName NVARCHAR(1023)
  3. AS
  4. DECLARE @ServerID AS INT
  5. SELECT @ServerID = Id FROM [SERVERS] WHERE [Servername] = @serverName
  6. -- Set the Server as InActive so no new instances can start.
  7. -- UPDATE [Servers] SET [isActive] = 0 WHERE [ServerName] = @serverName
  8. -- Set existing running instances at inactive.
  9. -- This will ensure any running instances are returned an empty file set and shutdown.
  10. UPDATE [Instances] SET [isActive] = 0, [EndTime] = GETUTCDATE() WHERE [ServerId] = @ServerID and [IsActive] = 1
  11. GO