• Grant Fritchey say:

    Yes wen your delete one database the phisical file is deleted to...

    but in my case, i have one aplication in ASP.NET, that aplication should recive the information of any server and create one database, make some operations and in the end should be deleted.

    Create is easy, but wen is the time to delete, is always saying that have some pendent connections and don't allow to delete... so i had to find one way to do it, in this case the aswer of Grant Fritchey:

    ALTER DATABASE [AdventureWorks]

    SET OFFLINE

    WITH ROLLBACK IMMEDIATE

    GO

    DROP DATABASE [AdventureWorks]

    GO

    Allow my asp.net to remove the database, even if there are some connections.... But the phisic files still on the data folder of SQL program, and the application is portable, so depending of the server, the path can be different.

    So to find it:

    Select filename From master..sysdatabases Where Name = 'mydatabase'

    And after the code of the on top. But for each database there are to files, one with mydb.mdf extension and other with mydb.ldm, the query on top returns the one with *.mdf, the other with VB string tratment is easy to have... so:

    - 1st i select the filename

    - 2st i delete the database

    - 3st i delete the phisic files of database