Reputation:
I have a SQL Server database that was created from VS2012. I located the database files for that. I would like to back up the database and move it to a different machine.
My application already has started up and is running. Do I need to somehow stop the database before I copy the files? I don't have SQL Server Management installed so if I have to do that I am not sure how to do it.
Can I just make a copy of the database and the log file and move them to another machine?
The database files are in my C:\Users\Melina folder. Will the VS2012 on the other machine be able to access the data files without me doing anything?I have the following connectionString:
<add
name="TestContext"
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=Test;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
Upvotes: 3
Views: 8253
Reputation: 15
$server = 'KALLESPC\SQLEXPRESS'; or $server = '.';
$link = mssql_connect($server, 'sa', 'phpfi');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
Upvotes: 0
Reputation: 76
Backup your database from original machine 1) Open SQL Server Management Studio, connect to your (LocalDb), select your database then right-mouse-click, choose Tasks -> Back Up ... 2) Remember the Destination path in Back Up Database dialog, then click OK
Copy the created .bak to your target machine
Install SQL Server on your target machine if it's not installed previously
Do the opposite operation Restore on your target machine 1) Open SQL Server Management Studio, in Object Explorer, select Databases, then right-mouse-click, select Restore Database, open Restore Database dialog 2) Give a name to To Database 3) Under Source for restore, choose From device, then browse to your copied .bak file, then click OK
Upvotes: 4