Do the system tables in the database also get restored?

Chaitanya Kiran 841 Reputation points
2021-10-20T14:06:44.757+00:00

When we restore a database from server A to server B, do the system tables in the database also get restored?

SQL Server | Other
{count} votes

4 answers

Sort by: Most helpful
  1. Michael Taylor 61,146 Reputation points
    2021-10-20T14:14:18.113+00:00

    The system tables for the database will get restored yes. If they didn't then you wouldn't have any schema, security or other settings and the DB would be useless. You'd end up having to restore the data and then set up the security and other settings again which wouldn't make sense.

    However server-level settings are not tied to a particular database and wouldn't be restored.


  2. Olaf Helper 47,596 Reputation points
    2021-10-20T15:03:33.863+00:00

    A restore of a backup is an exact 1:1 copy of the source database with all objects, without any exception.

    Which "system tables" do you mean?
    The content of e.g. DMV are not persisted.

    0 comments No comments

  3. Erland Sommarskog 131K Reputation points MVP Volunteer Moderator
    2021-10-20T21:44:42.64+00:00

    As other have said, a backup is full copy of the database. BACKUP works on a low level, and does not really understand tables. It simply writes pages to disk (or tape).

    If you think some data is missing, a possible explanation is that you did something like this:

    BACKUP DATABASE db TO DISK = 'C:\temp\existingfile.bak'
    RESTORE DATABASE db FROM DISK = 'C:\temp\existingfile.bak'
    

    In this case, BACKUP appends the backup to the existing file, but when you restore the database, RESTORE picks the first backup.

    You can do this:

    RESTORE HEADERONLY FROM DISK = 'C:\temp\yourbackup.bak'
    

    If you see more than row, this means that you have multiple backups. If there are five rows, and you want the most recent one, you need to add WITH FILE = 5 to your RESTORE command.

    And, no, this is not the most user-friendly design.

    0 comments No comments

  4. AmeliaGu-MSFT 14,011 Reputation points Microsoft External Staff
    2021-10-21T06:28:47.507+00:00

    Hi ChaitanyaKiran-2787,

    How are things going?
    Could you please share the detailed system tables in the database that have not been backed up?
    Please try to take a good new backup and restore it in the server B.

    Best Regards,
    Amelia

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.