Results 1 to 3 of 3

Thread: Aborting a backup

  1. #1
    Join Date
    Dec 2004
    Posts
    1

    Aborting a backup

    Hi,

    Is it possible to abort a BACKUP DATABASE transaction programmatically?

    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    If it is sql server find the process ID - sysprocess table and then
    KILL the process

  3. #3
    Join Date
    Feb 2003
    Posts
    1,048
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •