{"id":7175,"date":"2023-01-09T12:03:57","date_gmt":"2023-01-09T11:03:57","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=7175"},"modified":"2024-05-15T09:58:50","modified_gmt":"2024-05-15T08:58:50","slug":"mssql-single-user-mode-and-multi-user","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/mssql-single-user-mode-and-multi-user\/","title":{"rendered":"MSSQL single user mode and multi user"},"content":{"rendered":"\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"sqlserver\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">-- enter single user mode\nALTER DATABASE [DatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE\n\n-- single user mode can be used for restoring backups\nRESTORE DATABASE [DatabaseName] FROM DISK = '{escapedBackupFile}' WITH REPLACE\n\n-- restore multi user mode\nALTER DATABASE [DatabaseName] SET MULTI_USER\n\n\n-- when database is in restoring state, run next line\nRESTORE DATABASE [DatabaseName] WITH RECOVERY\n\n\n--------------------------------------------------------------------\n--   RESTORE DATABASE FROM SINGLE USER WITH EXISTING CONNECTION   --\n--------------------------------------------------------------------\n\n-- list connections\nEXEC sp_who\n \n-- kill process (connection):\nKILL &lt;pid>\n\n-- restore multi user mode\nALTER DATABASE [DatabaseName] SET MULTI_USER\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7175","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=7175"}],"version-history":[{"count":3,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7175\/revisions"}],"predecessor-version":[{"id":8546,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7175\/revisions\/8546"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=7175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=7175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=7175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}