Create copy of Db on same server (SQL STATEMENT):
CREATE DATABASE [gs-app-db-cpy] AS COPY OF [gs-app-db]
SSMS Backup options for on-prem server dbs:
Backup database [md-migration-himavaan] to disk =N’c:\gBaks\him.bak’
bak : Applicable for On-premise databases backups (From SSMS or SQLOPS tool : To create a bac file we Right Click Database >> Tasks >> Backup)
Backup and restore using BacPac file:
Create bacpac file : Applicable for Backups/Export Data Tier of Databases to/within Azure SQL Databases (From SSMS or SQLOPS tool : To create a bac file we Right Click Database >> Tasks >> Export Data Tier). BacPac is not consistent if data is cont. been written while BacPac is in progress so better is to create a copy of db and then create BacPac.
IMPORT BacPac file using Azure Portal:
Upload BacPac to some storage account and use import database feature on Azure portal. Note: provide correct admin username and password for that db otherwise import will fail.
POWERSHELL COPY DB SERVER TO SERVER:
New-AzureRmSqlDatabaseCopy -ResourceGroupName “myResourceGroup” ` -ServerName $sourceserver ` -DatabaseName “MySampleDatabase” ` -CopyResourceGroupName “myResourceGroup” ` -CopyServerName $targetserver ` -CopyDatabaseName “CopyOfMySampleDatabase”
Generate DB Scripts:
This can be used to generate schema or schema and data scripts for db.