SQL Backup Script for All Databases in SQL Server Instance
Undocumented stored procedure sp_Msforeachdb can help SQL administrators and t-sql developers to repeat tasks on each of sql databases running on the SQL Server instance.
Taking sql backup of all sql databases on a SQL Server can be considered as a repeatitive task for many administrators.
So it is certain that an SQL Server backup script using sp_Msforeachdb undocumented stored procedure will make it sql backups easier for many sql professionals.
Before dealing more on how sp_Msforeachdb can be used to create a sql backup script for taking backups of all sql databases, lets concantrate on t-sql BACKUP DATABASE command.
Here is how you can use the above sql backup procedure to backup database in your SQL Server.
MS SQL Backup Script using sp_Msforeachdb
And by using undocumented stored procedure sp_Msforeachdb, sql developers or SQL Server database administrators can take sql backup of all databases on the target SQL Server instance by using the following code.
If you have separate folders for your sql server databases, you can use the below sql backup script too.
If you are a SQL Database Administrator or T-SQL developer who prefer to use graphical user interfaces (GUI), you can use Microsoft SQL Server Management Studio SQL Server Backup Database Wizard as SQL Backup Tool.