Search This Blog

Wednesday 18 March 2009

Drop sybase devices

I recently installed a virtual machine from a flash archive. This machine had Sybase devices on raw devices which weren't accessible from the virtual machine. I knew I needed to reinstall these which is quite straightforward but because Sybase thought they existed, I couldn't drop them or access them. Below is what I tried.

1> Drop database
2> go

This gave an error saying the database was in use

1> sp_dropdevice
2>

This gave an error as it said the DB needed to be dropped.

1> dbcc dbrepair (DB_name, dropdb)
2> go

This gave a message telling me that I couldn't repair the database as it was not marked suspect. I couldn't mark it suspect as it hadn't initialised at start up time (because the devices weren't present).

I used to be excellent at this stuff but I rarely work on it any more. I knew there was a way to do this but it took some searching, eventually I found:

1> use master
2> go
1> sp_configure 'allow update', 1
2> go
1> begin tran
2> go
1> delete from sysusages where dbid =
2> go
1> commit
2> go
1> begin tran
2> go
1> delete from sysdatabases where dbid=
2> go
1> commit
2> go
1> sp_configure 'allow update', 0
2> go

This is the exact procedure I used and I am now happily reinstalling my databases.

No comments:

Post a Comment