This article demonstrates how to attach / detatch a database using SQL commands

Open the query analyzer, and enter either

To detatch the database sp_detach_db StuckIndoors

To attach a database sp_attach_single_file_db @dbname = 'StuckIndoors', @physname= 'E:\MSSQLData\data\StuckIndoors.mdf'

Average rating:

Comments

Peter, you might have indicated in the title of this piece that you're talking specifically about Microsoft SQL Server. These commands are specific only to SQL Server; anyone using Access, MySQL, Oracle, etc. would find this article useless, sorry!