<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pt-br">
		<id>http://wiki.mstech.com.br/index.php?action=history&amp;feed=atom&amp;title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados</id>
		<title>Fecha conexões ativas com o Banco de Dados - Histórico de revisão</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mstech.com.br/index.php?action=history&amp;feed=atom&amp;title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados"/>
		<link rel="alternate" type="text/html" href="http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;action=history"/>
		<updated>2026-05-07T19:31:46Z</updated>
		<subtitle>Histórico de revisões para esta página neste wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;diff=2113&amp;oldid=prev</id>
		<title>Daniel.alves em 16h22min de 23 de agosto de 2016</title>
		<link rel="alternate" type="text/html" href="http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;diff=2113&amp;oldid=prev"/>
				<updated>2016-08-23T16:22:31Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='pt-BR'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Edição anterior&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Edição das 16h22min de 23 de agosto de 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Linha 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linha 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Este script tem por finalidade fechar todas as conexões ativas à um determinado banco de dados. Útil quando existe a necessidade de se ter exclusividade de acesso ao banco de dados, como no caso de executar o '''restore''' de uma dada base.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Este script tem por finalidade fechar todas as conexões ativas à um determinado banco de dados. Útil quando existe a necessidade de se ter exclusividade de acesso ao banco de dados, como no caso de executar o '''restore''' de uma dada base.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;sql&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; line=&amp;quot;1&lt;/del&gt;&amp;quot; &amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;USE master&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;USE master&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;GO&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;GO&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Daniel.alves</name></author>	</entry>

	<entry>
		<id>http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;diff=1728&amp;oldid=prev</id>
		<title>Daniel.alves em 17h53min de 4 de agosto de 2016</title>
		<link rel="alternate" type="text/html" href="http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;diff=1728&amp;oldid=prev"/>
				<updated>2016-08-04T17:53:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='pt-BR'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Edição anterior&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Edição das 17h53min de 4 de agosto de 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l6&quot; &gt;Linha 6:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linha 6:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;declare @spid int&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;declare @spid int&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;declare @db_name varchar(100)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;declare @db_name varchar(100)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;set @db_name = '&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;BlueApi&lt;/del&gt;' -- coloque o nome &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;da base &lt;/del&gt;aqui&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;set @db_name = '&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;NomeBanco&lt;/ins&gt;' -- coloque o nome &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;do banco de dados &lt;/ins&gt;aqui&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;declare spid cursor for&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;declare spid cursor for&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;select spid&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;select spid&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Daniel.alves</name></author>	</entry>

	<entry>
		<id>http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;diff=1727&amp;oldid=prev</id>
		<title>Daniel.alves: Criou página com 'Este script tem por finalidade fechar todas as conexões ativas à um determinado banco de dados. Útil quando existe a necessidade de se ter exclusividade de acesso ao banco...'</title>
		<link rel="alternate" type="text/html" href="http://wiki.mstech.com.br/index.php?title=Fecha_conex%C3%B5es_ativas_com_o_Banco_de_Dados&amp;diff=1727&amp;oldid=prev"/>
				<updated>2016-08-04T17:52:37Z</updated>
		
		<summary type="html">&lt;p&gt;Criou página com &amp;#039;Este script tem por finalidade fechar todas as conexões ativas à um determinado banco de dados. Útil quando existe a necessidade de se ter exclusividade de acesso ao banco...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Este script tem por finalidade fechar todas as conexões ativas à um determinado banco de dados. Útil quando existe a necessidade de se ter exclusividade de acesso ao banco de dados, como no caso de executar o '''restore''' de uma dada base.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot; line=&amp;quot;1&amp;quot; &amp;gt;&lt;br /&gt;
USE master&lt;br /&gt;
GO&lt;br /&gt;
declare @spid int&lt;br /&gt;
declare @db_name varchar(100)&lt;br /&gt;
set @db_name = 'BlueApi' -- coloque o nome da base aqui&lt;br /&gt;
declare spid cursor for&lt;br /&gt;
select spid&lt;br /&gt;
from master.dbo.sysprocesses(nolock)&lt;br /&gt;
where dbid = db_id(@db_name) and spid &amp;gt; 50&lt;br /&gt;
union&lt;br /&gt;
select distinct request_session_id&lt;br /&gt;
from sys.dm_tran_locks (nolock)&lt;br /&gt;
where resource_database_id = db_id(@db_name) and request_session_id &amp;gt; 50&lt;br /&gt;
open spid&lt;br /&gt;
fetch next from spid into @spid&lt;br /&gt;
while @@fetch_status = 0&lt;br /&gt;
begin&lt;br /&gt;
exec ('kill ' + @spid)&lt;br /&gt;
fetch next from spid into @spid&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daniel.alves</name></author>	</entry>

	</feed>