SqlServer強(qiáng)制斷開(kāi)數(shù)據(jù)庫(kù)已有連接的方法建站知識(shí)
導(dǎo)讀:1建站知識(shí)在執(zhí)行建庫(kù)腳本時(shí),往往會(huì)先將原有的數(shù)據(jù)庫(kù)drop掉,由于SqlServer檢測(cè)到有數(shù)據(jù)連接時(shí)禁止執(zhí)行drop database操作,所以建網(wǎng)站seo優(yōu)化軟件seo網(wǎng)站優(yōu)化培訓(xùn)。
在執(zhí)行建庫(kù)腳本時(shí),往往會(huì)先將原有的數(shù)據(jù)庫(kù)drop掉,由于SqlServer檢測(cè)到有數(shù)據(jù)連接時(shí)禁止執(zhí)行drop database操作,所以建庫(kù)腳本經(jīng)常執(zhí)行失敗,為此我們需要一種能強(qiáng)制營(yíng)銷(xiāo)型網(wǎng)站建設(shè)斷開(kāi)數(shù)據(jù)庫(kù)已有連接的方法,可以過(guò)如下t-sql實(shí)現(xiàn):
復(fù)制代碼 代碼如下:
declare @i int declare cur cursor for select spid from sysprocesses where db_name(dbid)= 'Your_Database_Name' open cur fetch next from cur into @i while @@fetch_status=0 begin exec('kill '+@i) fetch next from cur into @i end cl網(wǎng)seo優(yōu)化趨勢(shì)ose cur de網(wǎng)站建設(shè)教程allocate cur
我們可以把這條sql寫(xiě)到建庫(kù)的批處理腳本里,放在腳本的開(kāi)始:復(fù)制代碼 代碼如下:
:: Disconnect existing Fortune database connections osql -S"%1" -U"%2" -P"%3" -Q"declare @i int declare cur cursor for select spid from sysprocesses where db_name(dbid)= ' Your_Database_Name ' open cur fetch next from cur into @i while @@fetch_status=0 begin exec('kill '+@i) fetch next from cur into @i end close cur deallocate cur"
相關(guān)網(wǎng)站seo優(yōu)化軟件seo網(wǎng)站優(yōu)化培訓(xùn)。聲明: 本文由我的SEOUC技術(shù)文章主頁(yè)發(fā)布于:2023-05-24 ,文章SqlServer強(qiáng)制斷開(kāi)數(shù)據(jù)庫(kù)已有連接的方法建站知識(shí)主要講述已有,標(biāo)簽,SqlServer強(qiáng)制斷開(kāi)數(shù)據(jù)庫(kù)已有連接的方法網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請(qǐng)保留鏈接: http://www.bifwcx.com/article/web_6284.html
為你推薦與SqlServer強(qiáng)制斷開(kāi)數(shù)據(jù)庫(kù)已有連接的方法建站知識(shí)相關(guān)的文章
-
通王TWCMS 2.0.3網(wǎng)站模板程序下載
(126)人喜歡 2024-01-15 -
Windows官方原版在哪里下載
(175)人喜歡 2024-01-15 -
WordPress網(wǎng)站模板發(fā)帖標(biāo)題顏色設(shè)置
(131)人喜歡 2024-01-07 -
修改discuz論壇帖子標(biāo)題80字符的長(zhǎng)度限制
(249)人喜歡 2024-01-07 -
wordpress程序調(diào)用不帶超鏈接的Tag標(biāo)簽
(234)人喜歡 2024-01-05 -
網(wǎng)站在不同時(shí)期需調(diào)整內(nèi)容更新的方向
(112)人喜歡 2023-08-12