IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID('dbo.verify_sync_folders') AND sysstat & 0xf = 4) DROP PROCEDURE dbo.verify_sync_folders GO CREATE PROCEDURE verify_sync_folders @dbName VARCHAR(30) = ' ', @devicePath VARCHAR(50) = ' ', @deviceShare VARCHAR(80) = ' ', @deviceFolder VARCHAR(30) = ' ', @archive VARCHAR(80) = ' ', @serverName VARCHAR(30) = ' ', @debug VARCHAR(5) = 'false' AS DECLARE @myName VARCHAR(30), @CMD VARCHAR(255), @CMDstatus INT /* Procedure verify_sync_folders will check for and create if not present, a folder with PKZIP and PKUNZIP along with a folder intended as a target for any zipped files originating in the first folder. This procedure requires that the admin subsystem file structure shell be in place before the procedure is executed. */ /* stop now if any parm was not provided */ IF (@dbName = ' ') OR (@devicePath = ' ') OR (@deviceShare = ' ') OR (@deviceFolder = ' ') OR (@archive = ' ') OR (@serverName = ' ') RETURN 1 SET NOCOUNT ON SELECT @myName = 'admin.verify_sync_folders' SELECT @CMD = 'dir ' + @devicePath EXEC @CMDstatus = dispatch @CMD, @myName, @debug IF (@CMDstatus <> 0) -- failed BEGIN SELECT @CMD = 'mkdir ' + @devicePath + '\' EXEC @CMDstatus = dispatch @CMD, @myName, @debug IF (@CMDstatus <> 0) RETURN @CMDstatus /* move a pkzip and pkunzip into the dump dump path */ SELECT @CMD = 'copy \\' + @serverName + '\' + @deviceShare + '\' + @deviceFolder + '\pkzip.exe \\' + @serverName + '\' + @deviceShare + '\' + @deviceFolder + '\' + @dbName EXEC @CMDstatus = dispatch @CMD, @myName, @debug IF (@CMDstatus <> 0) RETURN @CMDstatus SELECT @CMD = 'copy \\' + @serverName + '\' + @deviceShare + '\' + @deviceFolder + '\pkunzip.exe \\' + @serverName + '\' + @deviceShare + '\' + @deviceFolder + '\'+ @dbName EXEC @CMDstatus = dispatch @CMD, @myName, @debug IF (@CMDstatus <> 0) RETURN @CMDstatus END -- dump path does not exist /* make sure an archive path exists for this database */ SELECT @CMD = 'dir ' + @archive EXEC @CMDstatus = dispatch @CMD, @myName, @debug IF (@CMDstatus <> 0) -- not found BEGIN SELECT @CMD = 'mkdir ' + @archive + '\' EXEC @CMDstatus = dispatch @CMD, @myName, @debug IF (@CMDstatus <> 0) RETURN @CMDstatus END RETURN GO