久久久久久久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ù)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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.

通常為了解決這個問題,我只是重新啟動服務(wù)器.當(dāng)我們在我們的開發(fā)機(jī)器上的本地實(shí)例上進(jìn)行開發(fā)時,這很好.但是我們有一些程序員需要訪問數(shù)據(jù)庫,以及讓每個人編寫他們的更改腳本并將其放入 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ù).不幸的是,我在辦公室有另一個同事正在從事另一個項(xiàng)目,并且正在使用相同的數(shù)據(jù)庫服務(wù)器進(jìn)行開發(fā).為善起見,我想在不重新啟動 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í)行任何操作.在那段時間之后,它們將被回滾.所以它提供了一些保護(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的 SQL 觸發(fā)器)
sql search query with multiple optional search parameters(具有多個可選搜索參數(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 輸出中插入雙引號)
Delete rows from CTE in SQL SERVER(從 SQL SERVER 中的 CTE 中刪除行)
主站蜘蛛池模板: 亚洲成人三级 | 国产精品手机在线观看 | 日本理伦片午夜理伦片 | 蜜桃视频一区二区 | 草逼视频免费看 | 欧美高清一区二区 | 欧美成人精品一区二区三区 | 日本www视频 | 97免费在线视频 | 国产精品毛片va一区二区三区 | 国产免费成人 | 深夜福利av | 天天做天天干 | 国产精品久久久久久无人区 | 国产三级视频在线 | 日韩欧美在线观看视频 | 国产人成| 交换多p群乱高h文 | 五月婷婷av | 黄色日皮视频 | eeuss一区二区三区 | 97人人艹| 在线日韩 | 性生活毛片 | 亚洲国产精品一区二区三区 | 成人福利视频 | 五月婷婷色综合 | 天天爽夜夜爽夜夜爽精品视频 | 激情久久网 | 一区在线观看 | igao视频在线| 三上悠亚激情av一区二区三区 | 成人h片在线观看 | 国产福利在线观看 | 深夜福利网址 | 毛片av在线| 亚洲欧美网站 | 欧美在线视频免费 | 九九九精品视频 | 日韩av手机在线 | 能看的毛片|