At times it might be necessary to drop and recreate a Sybase ASE database. For example when you want to do a system copy from scratch and you need the current database to be cleaned up or when your DB is in inconsistent state and you want to created new DB and restore it.
Following command can be used to drop a database:
use master
go
drop database <dbname>
But if the DB is in inconsistent state you might get below error:
In such case use the below steps to drop the DB and create it again:
Note: DBCC DROPDB will only work if the database is marked as suspect:
First check if the DB is marked as suspect:
If the DB is not marked as suspect, this should be marked explicitly:
- Allow updatesNote: At this stage you need to restart your database services for the changes to take effect.
- Set the status of DB to suspect (320)
- Drop database using DBCC:
4. Dont forget to disable the updates by setting “Allow Updates” to Zero and restart the database.