declare @dbname sysname declare @basepath sysname declare @filename sysname declare @filedate varchar(8) set @basepath = 'c:\Backup\' select @filedate = convert(varchar(8), getdate(), 112) declare db_cursor cursor for select name from master.dbo.sysdatabases where name not in ('tempdb', 'model', 'msdb', 'master') open db_cursor fetch next from db_cursor into @dbname while @@fetch_status = 0 begin set @filename = @basepath + @filedate + '-' + @dbname + '.bak' print @filename backup database @dbname to disk = @filename with compression fetch next from db_cursor into @dbname end close db_cursor deallocate db_cursor