Is it possible to save under userdefined name in sql backup?

chandrurec
Member Posts: 560
Hi all,
I have configured the Job scheduler in SQL Server 2008 to take automatic backup in
\Backup folder. But It is storing in some default name. Is it possible to append the date on which the backup was taken along with the time at which the backup is taken.
If anyone knows how to append the date and time information to backup filename in SQL Server 2008, Kindly tell me how to do that?
Thanks in advance.
Regards,
Chandru.
I have configured the Job scheduler in SQL Server 2008 to take automatic backup in

If anyone knows how to append the date and time information to backup filename in SQL Server 2008, Kindly tell me how to do that?
Thanks in advance.
Regards,
Chandru.
0
Comments
-
Scheduled SQL Server backup jobs, if not defined manualy, always write the date and time of the backup (somename_backup_yyyymmddhhmm).0
-
That depends if you use 'Backup database across one or more files' or 'Create backup file for every database'. Using the file for every database option, SQL Server will create backup files like '[database_name]_backup_2010_10_18_162501_5892022.bak'.0
-
If you use a maintenance plan, it is easy to do it by playing with the parameters.
If you use a SQL Server agent job, you need to do it your self. This is the TSQL code I use to create a name with current date+time in it:DECLARE @file AS VARCHAR(200); SET @file='E:\Backup\DB_backup_' + REPLACE(CONVERT(DATE,GETDATE(),20),'-','') + '_' + REPLACE(REPLACE(CONVERT(TIME,GETDATE(),20),':',''),'.','') + '.BAK'; select @file
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi Kriki,
I got the required output by following the T-Script You have given.
Thank you so much.
Regards,
Chandru.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions