If you need to move a database or database file to another server or disk, and you do not want stored in the database, copy the backup to another server and then create the database backup, you can use the system and the stored procedure to use sp_detach_db sp_attach_db you detach the database and then reinstall it. Cancellation and databases of the system used when you want to run to move database files on a different physical hard drive disk space and wants to extend the existing file instead of adding a new database file to another disc.
Detach the database.
Move the database file (s) to the desired location on another server or disk.
Attach the database specifying the location of the file has changed new (n).
Following the removal of the database will be removed from SQL Server but it is intact form in the data and transaction log files, that the database. You can append this data and transaction log files into the database to any instance of SQL Server, including the server that was dropped from the database. After fixing the database are in the same condition it was when it sent was available.
[@ Dbname =] ‘dbname is the name and address. Dbname’is nvarchar (128), a default of NULL.
[Skip Checks @ =] ‘skip checks Parameter’ skip checks’ means that you can UPDATE STATISTICS run or cancel. Skip check is nvarchar (10), a default of NULL. If True skip checks, UPDATE STATISTICS is ignored. If is incorrect skip checks, UPDATE STATISTICS is run.
If you attach a database, you must have at least the name and physical location of the primary data file. If one or more of the modified database files have been able to detach the database, you must specify the name and physical location of files in addition to the main file.
[@ Dbname =] ‘database dbname’is name. dbname is nvarchar (128), a default of NULL.
[1 @ filename =] ‘filename_n’Is the database file name. filename_n is nvarchar (260), a default of NULL. It may take up to 16 file names.

