I am creating a SQL Server database programmatically during a conversion. If the conversion code fails I want to delete/drop the database. If I use the shortcut menu for the database in SQL Server Management Studio 2005 the "delete" option is disabled. DROP DATABASE command also fails with message "Cannot drop database "XYZ" because it is currently in use."
I have shutdown and restarted the SQL Server and the database will not drop.
Any direction?
2条答案
按热度按时间vom3gejh1#
A new search found the following script that worked:
Must have been some open transaction that was stopping the drop. Problem solved.
uqdfh47h2#
How long does your conversation takes.. Maybe you should consider using transactions, if that's an option. Just roll the transaction back when your conversation fails.