Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    19

    Unanswered: Restoring of database using SQL-DMO part 2

    Hi its me again, I posted a message some time ago concerning restoring of database.

    http://www.dbforums.com/showthread.p...36#post3582736

    My restore module basically restores a backup of a database file.

    I found that when I integrate my restore module with a login module, I am getting the same exclusive access error again. I also found out that the connection created for authenticating the user, remains sleeping even after it is closed, which in effect prevents my restore module to get exclusive access.

    What am I doing wrong? Any ideas appreciated, thanks for reading!

  2. #2
    Join Date
    Sep 2003
    Location
    Mumbai, India
    Posts
    36
    Run This before you restore database statement:
    declare @l_spid varchar(4)
    ,@l_hostname varchar(20)

    declare kill_cursor scroll cursor
    for
    select convert(varchar(4), spid), hostname from master..sysprocesses with (nolock)
    where db_name(dbid) = 'Your Database Name'

    open kill_cursor
    select @@cursor_rows

    fetch next from kill_cursor into
    @l_spid
    ,@l_hostname
    while (@@fetch_status = 0 )
    begin
    select @l_hostname Killed
    exec ( 'kill ' + @l_spid)
    fetch next from kill_cursor into
    @l_spid
    ,@l_hostname
    end
    close kill_cursor
    deallocate kill_cursor


    YOUR RESTORE DATABASE STATEMENT

  3. #3
    Join Date
    Nov 2003
    Posts
    19
    Thanks suresh. I will try that.

Posting Permissions

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