Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Perform an MSDE database backup through Transact-SQL

Total Hit ( 2644)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The MSDE database engine is 100% compatible with SQL Server and subject to the same license policy of the Jet engine. One of the fundamental differences between MSDE and SQL Server is the lack of any graphical tool for the administration. Many users take advantage of Access 2000 as administrative front-end for the MSDE databases, but how to operate if Access isn't avaible? For example, how to perform a fundamental operation such as the backup without the help of any external tool? In this case you can use the command line utility Osql.exe for executing the following T-SQL script (saved as BackupJob.sql) to create a new backup job and execute it through the sp_start_job stored procedure:

Click here to copy the following block
-- Backup job creation
USE msdb
EXEC sp_add_job @job_name = 'BackupJob',
@enabled = 1,
@description = 'BackupJob',
@owner_login_name = 'sa',
@notify_level_eventlog = 2,
@notify_level_email = 2,
@notify_level_netsend =2,
@notify_level_page = 2
@notify_email_operator_name = 'myMailAddress'
go
-- Data backup
USE msdb
EXEC sp_add_jobstep @job_name = 'BackupJob',
@step_name = 'msdb database backup',
@subsystem = 'TSQL',
@command = 'BACKUP DATABASE msdb TO DISK = ''c:\msdb.dat_bak''',
@on_success_action = 3,
@retry_attempts = 5,
@retry_interval = 5
go
-- Log file backup
USE msdb
EXEC sp_add_jobstep @job_name = 'myTestBackupJob',
@step_name = 'msdb Log backup',
@subsystem = 'TSQL',
@command = 'BACKUP LOG msdb TO DISK = ''c:\msdb.log_bak''',
@on_success_action = 1,
@retry_attempts = 5,
@retry_interval = 5
go
-- Server specification
USE msdb
EXEC sp_add_jobserver @job_name = 'BackupJob', @server_name = N'(local)'

-- Immediate job execution
USE msdb
EXEC sp_start_job @job_name = 'myTestBackupJob'

This script can be launched from the command line As Follows:

Click here to copy the following block
OSQL -Usa -P -i BackupJob.sql -n

In case you prefer to schedule the backup procedure instead of executing it immediately, it is possible to replace the sp_start_job stored procedure with sp_add_jobschedule, whose syntax is described in the Books Online.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.