Uninstall and automatic backup of sql server 2005 Description

  

Uninstall: Execute the command c:\\sqlserver2005\\Setup.exe /qb REMOVE=ALL INSTANCENAME=<InstanceName> where setup.exe is the installation after SQLEXPR_ADV.EXE decompression program. The reason for this is because the control panel is not clean when uninstalled, and the instance of sql is still there. This method is best. Automatic backup: Original: http://www.mssqltips.com/tip.asp?tip=1174 Idea: 1: Generate an automatic backup sql script, a storage process called sp_BackupDatabase.

1USE [master] 2GO 3/**//****** Object: StoredProcedure [dbo].[sp_BackupDatabase] Script Date: 02/07/2007 11:40:47 **** **/4SET ANSI_NULLS ON 5GO 6SET QUOTED_IDENTIFIER ON 7GO 8 910-- ============================================ ========== 11-- Author: Edgewood Solutions 12-- Create date: 2007-02-07 13-- Description: Backup Database 14-- Parameter1: databaseName 15-- Parameter2: backupType F=full , D=differential, L=log16-- ================================================= ===== 17CREATE PROCEDURE [dbo].[sp_BackupDatabase] 18 @databaseName sysname, @backupType CHAR(1) 19AS 20BEGIN 21 SET NOCOUNT ON; 2223 DECLARE @sqlCommand NVARCHAR(1000) 24 DECLARE @dateTime NVARCHAR(20) 2526 SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + 27 REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','') 2829 IF @backupType = 'F' 30 SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + 31 ' TO DISK = ''C :\\Backup\\' + @databaseName + '_Full_' + @dateTime + '.BAK''' 32 33 IF @backupType = 'D' 34 SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + 35 ' TO DISK = ' 'C:\\Backup\\' + @databaseName + '_Diff_' + @dateTime + '.BAK'' WITH DIFFERENTIAL' 36 37 IF @backupType = 'L' 38 SET @sqlCommand = 'BACKUP LOG ' + @databaseName + 39 ' TO DISK = ''C:\\Backup\\' + @databaseName + '_Log_' + @dateTime + '.TRN''' 40 41 EXECUTE sp_executesql @sqlCommand 42END

Note that you have to compile it. 2: Call a sql script 2 of this stored procedure. This script can be called by an external program, using sqlcmd.exe to explain the execution.

1sp_BackupDatabase 'master', 'F'2GO3sp_BackupDatabase 'model', 'F'4GO5sp_BackupDatabase 'msdb', 'F'6GO7QUIT

3: Set up a scheduled task, execute the above script every day 2. < Br>sqlcmd -S serverName -E -i C:\\Backup\\Script 2.sql

The above statement is the parameter of the scheduled task "Run".

Copyright © Windows knowledge All Rights Reserved