1. Open the command prompt on the server.
2. Connect to an instance of SQL Server 2005 Express Edition, from the command prompt, by using the following sqlcmd command:
sqlcmd -S Server\InstanceWhere Server is the name of the computer and Instance is the name of the instance
3. Type the following command, when they are connected:
USE [master]GOCREATE DATABASE [database_name] ON( FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<database name>.mdf’ ),( FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<database name>.ldf’ )FOR ATTACH ;GOWhere database_name is the name of the database they want to attach, FileName is the path and filename of the database file and the log file, and FOR ATTACH specifies that the database is created by attaching an existing set of operating system files.
4. Type the following commands to verify that the database has been attached:
select name from sys.databasesgo
5.The sqlcmd tool displays the names of all databases attached to this instance of SQL Server Express. In the list, Developers should see the database name they provided in step 3.