'How do use Sqlcmd to migrate full databases (not just tables)?

I am working on migrating databases from a 2017 SQL server to a 2016 version. The databases I am working with are hundreds of gigabytes so I am using generate script along with sqlcmd to restore.

However, when I restore the database on the new server it creates the tables and files them under the Master db rather than recreating the entire saved database. I want the exact same DB to be restored on the new server. Can anyone help me figure out what I am doing wrong?

Steps taken:

  1. Generate Script - Include Data and Schema
  2. Open cmpt prompt and enter: sqlcmd -S (servername) -i (file location)

The tables populate under the Master database instead of restoring the original database standalone.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source