久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何獲得對 SQL Server 2005 數(shù)據(jù)庫的獨(dú)占訪問權(quán)限來

How to gain exclusive access to SQL Server 2005 database to restore?(如何獲得對 SQL Server 2005 數(shù)據(jù)庫的獨(dú)占訪問權(quán)限來恢復(fù)?)
本文介紹了如何獲得對 SQL Server 2005 數(shù)據(jù)庫的獨(dú)占訪問權(quán)限來恢復(fù)?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

每當(dāng)我在 SQL Server 中恢復(fù)我的數(shù)據(jù)庫備份時(shí),都會(huì)出現(xiàn)以下錯(cuò)誤:

Whenever I restore a backup of my database in SQL Server I am presented with the following error:

Msg 3101, Level 16, State 1, Line 1
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

通常為了解決這個(gè)問題,我只是重新啟動(dòng)服務(wù)器.當(dāng)我們在我們的開發(fā)機(jī)器上的本地實(shí)例上進(jìn)行開發(fā)時(shí),這很好.但是我們有一些程序員需要訪問數(shù)據(jù)庫,以及讓每個(gè)人編寫他們的更改腳本并將其放入 Subversion 正在變成一場噩夢.不管怎樣,我們的簡單解決方案是將它放在辦公室的共享服務(wù)器上,并偶爾備份服務(wù)器,以防有人搞砸了數(shù)據(jù).

Usually to get around this I just restart the server. This was fine when we were developing on our local instance on our development machines. But we have a few programmers that need to access the database, and the logistics of having everyone script their changes and drop them into Subversion was becoming a nightmare. Regardless our simple solution was to put it on a shared server in the office and backup the server occasionally in case someone screwed up the data.

好吧,我搞砸了數(shù)據(jù),需要恢復(fù).不幸的是,我在辦公室有另一個(gè)同事正在從事另一個(gè)項(xiàng)目,并且正在使用相同的數(shù)據(jù)庫服務(wù)器進(jìn)行開發(fā).為善起見,我想在不重新啟動(dòng) SQL Server 和可能中斷他的工作的情況下進(jìn)行恢復(fù).

Well, I screwed up the data and needed to restore. Unfortunately, I have another co-worker in the office who is working on another project and is using the same database server for development. To be nice I'd like to restore without restarting the SQL Server and possibly disrupting his work.

有沒有辦法在 T-SQL 中編寫腳本以獲取獨(dú)占訪問或刪除所有連接?

Is there a way to script in T-SQL to be able to take exclusive access or to drop all connections?

推薦答案

您可以通過以下方式強(qiáng)制數(shù)據(jù)庫脫機(jī)并斷開連接:

You can force the database offline and drop connections with:

EXEC sp_dboption N'yourDatabase', N'offline', N'true'

或者你可以

ALTER DATABASE [yourDatabase] SET OFFLINE WITH
ROLLBACK AFTER 60 SECONDS

回滾指定是否正在執(zhí)行任何操作.在那段時(shí)間之后,它們將被回滾.所以它提供了一些保護(hù).

Rollback specifies if anything is executing. After that period they will be rolled back. So it provides some protection.

抱歉,我沒有正確思考/閱讀.您可以重新聯(lián)機(jī)并備份.在 Stack Overflow 上還有一篇關(guān)于 T-SQL 片段的帖子,用于刪除所有連接而不是先離線連接:SQL Server 的隱藏功能

Sorry I wasn't thinking/reading right. You could bing back online and backup. There was also a post on Stack Overflow on a T-SQL snippet for dropping all connections rather than binging offline first: Hidden Features of SQL Server

這篇關(guān)于如何獲得對 SQL Server 2005 數(shù)據(jù)庫的獨(dú)占訪問權(quán)限來恢復(fù)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

SQL trigger on Truncate(截?cái)鄷r(shí)的 SQL 觸發(fā)器)
sql search query with multiple optional search parameters(具有多個(gè)可選搜索參數(shù)的 sql 搜索查詢)
SQL Efficiency: WHERE IN Subquery vs. JOIN then GROUP(SQL 效率:WHERE IN 子查詢 vs. JOIN 然后 GROUP)
Retrieving XML element name using t-SQL(使用 t-SQL 檢索 XML 元素名稱)
Insert double quotes into SQL output(在 SQL 輸出中插入雙引號(hào))
Delete rows from CTE in SQL SERVER(從 SQL SERVER 中的 CTE 中刪除行)
主站蜘蛛池模板: 北条麻妃视频在线观看 | 人和拘一级毛片c | 精品综合久久久 | 久久青 | 午夜私人影院在线观看 | 99精品一区二区 | 综合久久亚洲 | 国产一区二区三区在线免费 | 成人黄色av网站 | 在线午夜| 色久影院 | 日韩中文在线观看 | 久久亚洲二区 | 成人深夜福利 | 欧美久久电影 | 日韩久久久久 | 中文字幕av中文字幕 | 久久99久久99 | 国产精品一区一区 | 中文字幕日韩欧美 | 日本理论片好看理论片 | 免费国产视频 | 久久精品99国产精品 | 国产成人一区二区三区精 | 日本不卡在线视频 | 5060网一级毛片 | 最新免费黄色网址 | a欧美| 99一区二区 | 亚洲www啪成人一区二区 | 久久精品无码一区二区三区 | 91欧美| 99久久精品国产一区二区三区 | 欧美一区成人 | 精品国产18久久久久久二百 | 亚洲国产日韩欧美 | 一区二区在线免费观看 | 久久精品亚洲 | 亚洲欧美一区二区三区在线 | 天天艹| 亚洲精品成人在线 |