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

推荐订阅源

Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
量子位
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
Y
Y Combinator Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
B
Blog
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
博客园 - 聂微东
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

博客园 - 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