Sometimes you need to drop a database from within code and without using SQLDMO. But DROP DATABASE will fail if there are any active connections exist. So below is a small script that kills all active connections on particular database and drops the database at the end. Remeber to replace <<DATABASE_NAME>> with your actual database name :) 1: SET
2: NOCOUNT ON
3: DECLARE
...