Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
avipenina
Starting Member
44 Posts |
Posted - 2007-12-29 : 03:13:44
|
| Hi,how can i take only the difference between those 2 sql scriptsselect distinct database_namefrom msdb.dbo.backupsetselect namefrom sys.databaseswhere name not in ('master','model','tempdb','msdb')i tell you what i want to achieve.i've an ERP program that create new database dynamiclly every 2-3 month.i want that this newlly created database will be backup once when it's created with full backup but only once on creation.so i think about query the sys.databases and then query themsdb.dbo.backupset to see if this database where backup sometime.or perhaps you have a better idea?Thx |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-29 : 10:39:30
|
| select d.name,b.backup_start_date,b.backup_finish_date from sys.databases dleft outer join msdb.dbo.backupset bon b.database_name = d.namewhere d.name not in ('master','model','tempdb','msdb')this gives all db info along with backup info if one exists. using this i think you can check whether it was backed up ever. Just check for condition b.database_name IS NULL to get dbs which havent been backed up yet and b.database_name IS NOT NULL to get dbs which have already been backed up. |
 |
|
|
|
|
|