Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Restore with relocate database files location in powershell

$
0
0
Please help me to modify this script as relocate database files location means like with move ... this will help mewrite-host "Restoring Databases"foreach ($database in $databases){write-host $databaseinvoke-sqlcmd -Query "USE [master]ALTER DATABASE [$database] SET SINGLE_USER WITH ROLLBACK IMMEDIATERESTORE DATABASE [$database] FROM DISK = N'H:\KMTemp\$database.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5ALTER DATABASE [$database] SET MULTI_USERGO" -ServerInstance $destinationserver -QueryTimeout 10000}

Viewing all articles
Browse latest Browse all 467

Trending Articles