Hi,
Is it possible to abort a BACKUP DATABASE transaction programmatically?
Thanks
Printable View
Hi,
Is it possible to abort a BACKUP DATABASE transaction programmatically?
Thanks
If it is sql server find the process ID - sysprocess table and then
KILL the process
I added in checks for the database name and the username, but those are optional. You may have to adjust the text of the cmd call. You could also check the last_batch field to look for one that has been running for a certain period of time.
Declare @SQL varchar(100)
SELECT Top 1 @SQL = 'Kill ' + Cast(spid as varchar)
FROM sysprocesses
Where cmd = 'BACKUP DATABASE'
And DB_NAME(dbid) = 'MyDatabase'
And SUSER_SNAME(sid) = 'domain\NTUsername'
Exec(@SQL)