惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
G
Google Developers Blog
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园 - 叶小钗
D
DataBreaches.Net
D
Docker
月光博客
月光博客
博客园 - 司徒正美
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - helloworld22

An excellent mockup tool -- Balsamiq Impression of Team Foundation Server 2010 Impression Of Book – Beautiful Architecture (翻译)十分钟内安装,配置,使用Windows Server AppFabric jQuery插件floatIt,浮动div并居中在上方或者下方 - helloworld22 - 博客园 some useful links for dealing with blg file and performance analyses The time zones of Event log 用证书实现windows 2003下IIS的SSL安全通信 5 Whys Quickly Getting to the Root of a Problem Outlook 2007 Conflicts With Google Desktop Encourage Sentences Collections 标准Singleton设计模式,多线程下 Be careful when you compare the GUID with a string Jmail 64bit 64位 不支持 machineKey - helloworld22 - 博客园 Error Install MS SQL Server Express in Windows XP SP3 / MSXML6 SP2 Sql 2005 Database diagram support objects cannot be installed because this database does not have a valid owner An error occurred during the execution of xp_cmdshell. A call to 'LogonUserW' failed with error code: '1385' Page Load called twice With FireFox - helloworld22
kill all user in a database, very useful
helloworld22 · 2009-12-08 · via 博客园 - helloworld22

It's very useful to tackle a locked database, when you decide to restore it.

Declare   @tblConnectedUsers   Table   (  
  SPID int )  
   
  Declare   @vcSQLText varchar(200),  
  @iSPID int  
   
  --Get   the   currently   connected   users  
  Insert   into     @tblConnectedUsers  
  Select   p.spid  
  from   master.dbo.sysprocesses   p   (nolock)  
  join   master..sysdatabases   d   (nolock)   on   p.dbid   =   d.dbid  
  Where   d.[name]   =   'dbname'   -->   database   name   here  
   
  --Loop   though   the   connected   users   and   kill   their   connections  
  While   1   =   1  
  Begin  
   
  Select   top   1   @iSPID   =   SPID  
  From     @tblConnectedUsers  
  Where   SPID   >   IsNull(@iSPID,   0)    
  order   by   SPID   asc  
   
  --   break   when   there   are   no   more   SPIDs  
  If   @@RowCount   =   0  
  Break  
   
  --Build   the   SQL   string  
  Set   @vcSQLText   =   'Kill   '   +   Convert(varchar(10),   @iSPID)  
   
  Exec(   @vcSQLText   )  
   
  End