HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Does T-SQL MOVE actually move the database, or just copy?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thesqljustmovedatabaseactuallydoescopy

Problem

I'm a bit confused over the T-SQL command MOVE. I have a statement saying:

MOVE 
N'Prod_Database_Data' 
TO 
N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Test_Database.mdf'
GO


The same statement is used on the log: Prod_Database_Log. I think the statement just makes a copy of the database and not actually moves the original database. Am I right or have I missed something fundamentally crucial?

Solution

There is no MOVE command.

There is the "RESTORE" command with arguments "WITH MOVE"

This deletes the old MDF and LDF files (if database already exists) and recreate the MDF/LDF files (and NDFs etc) where specified

Context

StackExchange Database Administrators Q#4637, answer score: 9

Revisions (0)

No revisions yet.