Sql-server – Does the SQL Server Backup Database Command also backup views from a Database

backuprestoresql serverview

I have a backup job (SQL Server Agent job) which will iterate through all of our SQL Server databases in SSMS, invoke the BACKUP DATABASE command to create a .bak file on a different server. This other server has its own job iterating through all of the .baks and restoring them (with the RESTORE DATABASE command).

EDIT: The server running the RESTORE job restores the .baks into its own installation of SSMS

The jobs report success in the SQL Agent job history so I'm wondering whether or not these jobs should also backup and restore the Views in the databases (as they haven't seemed to) or if this is an indication that the scripts aren't quite working?

Best Answer

The backup command backs up views, stored procedures, user-defined functions and so on.To test:

  • Create a database
  • Create a table
  • Insert something in it
  • Create a view on this table
  • Restore the database with another name; or
  • Drop the database and restore the previous .bak