Steps to attach a database with different name:
you can also copy by using the Sql-server Management studio:
- Detach database from local PC
- Copy the mdf and ldf files and rename them.
- Copy\Move the files to the server directory where the original Database is stored.
- Use the below code
USE [master]
GO
CREATE DATABASE [example_db] ON ( FILENAME = N'D:\Data\example_db.mdf' ),
( FILENAME = N'E:\Logs\example_db_log.ldf' )FOR ATTACH
GO
you can also copy by using the Sql-server Management studio:
- go to database and tasks->Copy Database
- Select the source and destination server (same if you wants to make a copy on the same server)
- change the destination database name to required.
- Done