/ * Database backup stored procedures * // * Support for server to back up data from the local machine * / - Author: yoncenCREATE PROCEDURE up_dbbackup (@backup_db_name VARCHAR (128), @ filename VARCHAR (128), / * backup path filename * / @ flag VARCHAR (60) OUTPUT) ASSET NOCOUNT ONDECLARE @sql NVARCHAR (4000), @ par NVARCHAR (1000) IF NOT EXISTS (SELECT * FROM master..sysdatabases WHERE name = @ backup_db_name) BEGIN SELECT @ flag = 'database ' @ backup_db_name ' does not exist! 'Returnendelsebegin if Right (@ filename, 1) <>' / 'and charindex (' / ', @ filename) <> 0 begin / * definition flag * / declare @LFlag int execute @LFlag = master..xp_cmdshell 'Dir z:' if @Lflag <> 0 begin / * established a full shared directory DB on client 192.168.2.45, specify a username and password .Win98 users do not need username and password * / execute @ Lflag = master..xp_cmdshell 'net use z: //192.168.2.45/db $ test /user:ca.atc/test' if @Lflag <> 0 begin select @ flag = 'server creation directory failed!' Return End end SELECT @par = '@ filename VARCHAR (1000)' SELECT @ sql = 'BACKUP DATABASE' @ backup_db_name 'TO DISK = @ filename WITH INIT' EXECUTE sp_executesql @ sql, @ par, @ filename EXECUTE master..xp_cmdshell 'NET USE Z: / delete 's Elect @ flag = 'database' @ backup_db_name 'backup success!' ReturnendelseBegin select @ flag = 'database backup path error!' Returnendend
** The above process is passed under SQL Server 7.0
** Thank http://www.myf1.net/bbs (Visual FoxPro Help Forum)