From 66eb53fadc0954e013cfaf421acaa3d6b0321493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ho=CC=88rler?= Date: Fri, 13 Jul 2018 21:17:48 +0200 Subject: [PATCH] Added and enhanced SQL Querys and connection blocker --- EHEC_Server/EHEC_Server/Web.config | 4 ++-- SQL/EHEC_DB_Query.sql | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/EHEC_Server/EHEC_Server/Web.config b/EHEC_Server/EHEC_Server/Web.config index e2466e9..3fd839c 100644 --- a/EHEC_Server/EHEC_Server/Web.config +++ b/EHEC_Server/EHEC_Server/Web.config @@ -30,8 +30,8 @@ - - + + diff --git a/SQL/EHEC_DB_Query.sql b/SQL/EHEC_DB_Query.sql index 00b1f2f..3b863de 100644 --- a/SQL/EHEC_DB_Query.sql +++ b/SQL/EHEC_DB_Query.sql @@ -11,16 +11,25 @@ -- 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 existiert bereits, sie wird nun geloescht und neu Gebaut' + PRINT 'EHEC_DB already EXISTS, db will be deleted for a new creation.' USE [master]; DROP DATABASE EHEC_DB; END; ELSE BEGIN; - PRINT 'EHEC_DB existiert noch nicht, die Datenbank wird nun neu Gebaut'; + PRINT 'EHEC_DB does NOT EXISTS, the db will be created now...'; END; GO @@ -273,9 +282,11 @@ VALUES ('EHEC-D'), ('EHEC-E') GO - - -- -------------------------------------------------- -PRINT 'Erfolgreich!'; +PRINT 'Set Singleuser mode back to Multiuser mode.'; +-- set DB back to Multiuser so multiconnections are alowed again. +ALTER DATABASE EHEC_DB SET MULTI_USER +-- -------------------------------------------------- +PRINT 'Successfull created your DB!'; -- Script has ended -- -------------------------------------------------- \ No newline at end of file