SOLVED Event ID 14421 cannot attach a database that was being restored

Had a tough time when I accidentally detached the secondary database which was in standby mode with log shipping enabled from the primary database.

I was lucky that although my secondary database server was offsite, my database was just around 900 MB. Here's what helped:

 

On the primary database server

  1. Take a full backup of the database
  2. compress it (My compressed database was around 170 MB)
  3. Copy over the backup to the secondary database server.

On the secondary database server

  1. decompress the backup database
  2. Delete/move the the physical database file
  3. create a new database with the same name as was earlier
  4. Restore the database from the backup you just moved

Once the restore is completed, the database will start replaying the logs. After the process is completed, you should see the database back to standby / read-only state.