Skip to content

Instantly share code, notes, and snippets.

@fnzv
Created June 17, 2019 08:44
Show Gist options
  • Save fnzv/b8e31b0eea9478195e573d3f7fbc068e to your computer and use it in GitHub Desktop.
Save fnzv/b8e31b0eea9478195e573d3f7fbc068e to your computer and use it in GitHub Desktop.
Useful MSSQL Scripts
SELECT ' DROP DATABASE [' + NAME + ']' FROM sys.sysdatabases where name like 'PREFIX%'
#Import-Module dbatools
# https://medium.com/@Luis_Palacios/restoring-multiple-database-in-sql-server-from-bak-files-751051798ab4
$databaseDirectory = "D:\Backup\"
Restore-DbaDatabase -SqlInstance localhost -Path ("{0}{1}" -f $databaseDirectory, "DB_NAME_1.bak")
Restore-DbaDatabase -SqlInstance localhost -Path ("{0}{1}" -f $databaseDirectory, "DB_NAME_2.bak")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment