A database is a collection of data that is organized according to certain rules and resides in the computer's memory. It characterizes the current state of a specific subject area.
Necessary
- - computer;
- - server;
- - Sql database.
Instructions
Step 1
Go to SQL Server Management Studio to attach the database, then go to Object Explorer and connect to the MicrosoftSQL Server Database Engine instance, expand it. Call the context menu on the "Databases" node. Click on the "Attach" command.
Step 2
In the "Attach databases" dialog box, click on the "Add" button, select in the "Database files location" window the required disk where the database is located, expand the folder tree to search and select a file in Mdf format. If you try to select an already attached base, an error will occur. To change its name, enter it in the Attach As column in the Attach Databases window.
Step 3
Change the owner, if necessary, when attaching the database, to do this, select the desired value in the "Owner" field. If everything is ready to connect the database to the server, click on the "OK" button. The newly attached database will only appear in the Databases node in the browser after you refresh the view. To do this, click on the object browser, go to the "View" menu, select the "Refresh" command.
Step 4
Note that all data files must be available when attaching the database to the server. If the data file has a different path from the one originally created or from the last attachment, specify the current path to the file. When connecting an encrypted database to the server for the first time, open the database master key by running the command: OPEN MASTER KEY DECRYPTION BY PASSWORD = "Enter your password".
Step 5
Turn on automatic key decryption. If the database is both writable and readable, attach the log file in a new location. Store them until the base joins without them. If the database has one log file and you do not specify a new location for it, the operation will use the old file location.