Does anyone have a script I can automate that will 1) Check for inactive db connections, 2) Kill those inactive db connections?
Thanks,
Warren
DECLARE @.sql varchar(4000)
WHILE 1=1
BEGIN
SET @.sql = (SELECT TOP 1 'KILL ' + CAST(spid AS VARCHAR(10))
FROM master.dbo.sysprocesses WHERE DATEDIFF(hh, last_batch,
GETDATE()) >= 6
AND spid <> @.@.spid AND spid >= 50)
IF @.sql IS NULL BREAK
EXEC (@.sql)
END
Just schedule it as a job to run at regular intervals. It kills all
processes that have been inactive for more than 6 hours.
Jacco Schalkwijk
SQL Server MVP
"Warren" <anonymous@.discussions.microsoft.com> wrote in message
news:AFF451DE-ADDC-4244-B10A-697A37706CFC@.microsoft.com...
> Does anyone have a script I can automate that will 1) Check for inactive
db connections, 2) Kill those inactive db connections?
> Thanks,
> Warren
|||Thanks Jacco!!!!
Warren
Showing posts with label automate. Show all posts
Showing posts with label automate. Show all posts
Friday, March 23, 2012
Script to check inactive db connections
Does anyone have a script I can automate that will 1) Check for inactive db
connections, 2) Kill those inactive db connections?
Thanks,
WarrenDECLARE @.sql varchar(4000)
WHILE 1=1
BEGIN
SET @.sql = (SELECT TOP 1 'KILL ' + CAST(spid AS VARCHAR(10))
FROM master.dbo.sysprocesses WHERE DATEDIFF(hh, last_batch,
GETDATE()) >= 6
AND spid <> @.@.spid AND spid >= 50)
IF @.sql IS NULL BREAK
EXEC (@.sql)
END
Just schedule it as a job to run at regular intervals. It kills all
processes that have been inactive for more than 6 hours.
Jacco Schalkwijk
SQL Server MVP
"Warren" <anonymous@.discussions.microsoft.com> wrote in message
news:AFF451DE-ADDC-4244-B10A-697A37706CFC@.microsoft.com...
> Does anyone have a script I can automate that will 1) Check for inactive
db connections, 2) Kill those inactive db connections?
> Thanks,
> Warren|||Thanks Jacco!!!!
Warren
connections, 2) Kill those inactive db connections?
Thanks,
WarrenDECLARE @.sql varchar(4000)
WHILE 1=1
BEGIN
SET @.sql = (SELECT TOP 1 'KILL ' + CAST(spid AS VARCHAR(10))
FROM master.dbo.sysprocesses WHERE DATEDIFF(hh, last_batch,
GETDATE()) >= 6
AND spid <> @.@.spid AND spid >= 50)
IF @.sql IS NULL BREAK
EXEC (@.sql)
END
Just schedule it as a job to run at regular intervals. It kills all
processes that have been inactive for more than 6 hours.
Jacco Schalkwijk
SQL Server MVP
"Warren" <anonymous@.discussions.microsoft.com> wrote in message
news:AFF451DE-ADDC-4244-B10A-697A37706CFC@.microsoft.com...
> Does anyone have a script I can automate that will 1) Check for inactive
db connections, 2) Kill those inactive db connections?
> Thanks,
> Warren|||Thanks Jacco!!!!
Warren
Tuesday, March 20, 2012
Script objects
Is there anyway to automate the scripting of tables,views, functions, and
procedures for a database to run nightly?
Thanks,
Doug Stiershttp://www.karaszi.com/sqlserver/in...rate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Doug Stiers" <doug@.nospam.com> wrote in message news:epYawYoEEHA.3976@.TK2MSFTNGP12.phx.gbl
..
> Is there anyway to automate the scripting of tables,views, functions, and
> procedures for a database to run nightly?
> Thanks,
> Doug Stiers
>
procedures for a database to run nightly?
Thanks,
Doug Stiershttp://www.karaszi.com/sqlserver/in...rate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Doug Stiers" <doug@.nospam.com> wrote in message news:epYawYoEEHA.3976@.TK2MSFTNGP12.phx.gbl
..
> Is there anyway to automate the scripting of tables,views, functions, and
> procedures for a database to run nightly?
> Thanks,
> Doug Stiers
>
Subscribe to:
Posts (Atom)