Você pode fazer isso usando um procedimento de loop de banco de dados não documentado.
use [master]
go
set quoted_identifier off
exec sp_MSforeachdb "
if ( '?' not in ( 'master', 'msdb', 'model', 'tempdb' ) )
begin
BACKUP DATABASE [?] TO DISK = N'J:\SQLBACKUPS\?.bak' WITH NOFORMAT, INIT, NAME = N'?-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'?' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'?' )
if ( @backupSetId is null )
begin
raiserror(N'Verify failed. Backup information for database ''?'' not found.', 16, 1)
end
RESTORE VERIFYONLY FROM DISK = N'J:\SQLBACKUPS\?.bak' WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
end
"