From f7be1ac531d1909f3ad025481e418b4ff9553498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ho=CC=88rler?= Date: Sun, 29 Jul 2018 11:05:07 +0200 Subject: [PATCH] Integrate check for connections into check for DB existance to avoid error on new creations of EHEC_DB --- SQL/EHEC_DB_Query.sql | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/SQL/EHEC_DB_Query.sql b/SQL/EHEC_DB_Query.sql index aa13d4d..bf2fc18 100644 --- a/SQL/EHEC_DB_Query.sql +++ b/SQL/EHEC_DB_Query.sql @@ -11,20 +11,14 @@ -- 180629 Ivan, Add inserts for fixed lists -- -------------------------------------------------- --- Set DB toSingle User so open connections do not block --- -------------------------------------------------- -PRINT 'Set Multiuser to Singleuser so all open connections are cut...'; -use master -ALTER DATABASE EHEC_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE --- -------------------------------------------------- - - - -- Auskommentieren für Löschung der Datenbank IF db_id('EHEC_DB') is not null BEGIN; - PRINT 'EHEC_DB already EXISTS, db will be deleted for a new creation.' + PRINT 'EHEC_DB already EXISTS, Set Multiuser to Singleuser so all open connections are cut...'; USE [master]; + -- Set DB toSingle User so open connections do not block Destroy of DB + ALTER DATABASE EHEC_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE + PRINT 'DB will be deleted for a new creation.' DROP DATABASE EHEC_DB; END; ELSE