I am using a custom made application that is using MSDE 2000 transact SQL. Thing is that I've made a simple batch file in order to save databases automatically every day but it seems I made a mistake... I never expected the server to save in the same file if the file already exists (thought it will overwrites it) in the destination folder and now I have a single file with multiple backups in it. Is there a way to separate backups within this file and to extract only the last backup? Restoring this backup file recreates the database with no error but it actually restores the first backup (the oldest).
The line used to save database is something like this:

osql -Usa -P -n -Q "BACKUP DATABASE ciel1 TO DISK = 'e:\BackUp2\Ciel1_1.bak'"

Thanks in advance for any help.....:)...

I am using a custom made application that is using MSDE 2000 transact SQL. Thing is that I've made a simple batch file in order to save databases automatically every day but it seems I made a mistake... I never expected the server to save in the same file if the file already exists (thought it will overwrites it) in the destination folder and now I have a single file with multiple backups in it. Is there a way to separate backups within this file and to extract only the last backup? Restoring this backup file recreates the database with no error but it actually restores the first backup (the oldest).
The line used to save database is something like this:

osql -Usa -P -n -Q "BACKUP DATABASE ciel1 TO DISK = 'e:\BackUp2\Ciel1_1.bak'"

Thanks in advance for any help.....:)...

I'm not sure if you can separate it in the same file but you could simply rename the file with a datetime stamp after the file is created. Put something along these lines in the .bat file to rename it.
It's not exactly what you were looking for but may be an easy work around.
To Rename Any File With Date And Time Padded
set dd = %date% %Time%
Ren File_To_Rename.txt NewFileName__%dd:~0,2%_%dd:~3,2%_%dd:~6,4%___%dd:~11,2%_%dd:~14,2%.txt
Output
--------
NewFileName__22_05_2009__6_20.txt

Thanks for the idea Dean but I have already resolved that issue for the future backups. I have created an automated task that puts all backups into an archive and adds the date to the name since it both saves space and avoid future problems. Once the archive is created then all files are deleted. The problem remains though with those files already created.....:(....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.