/ * 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? / * Define the flag * /? Declare @LFlag int? Execute @lflag = master..xp_cmdshell 'DIR Z:'? If @lflag <> 0? Begin ??? / * established a full sharing directory on the client 192.168.2.45 DB, specify a username and password .Win98 users do not need username and password * / ??? execute @ lflag = master..xp_cmdshell 'net using 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 =' @ '? SELECT @ sql =' filename VARCHAR (1000) BACKUP DATABASE ' @ backup_db_name ' TO DISK = @ filename WITH INIT NET USE Z 'EXECUTE sp_executesql @ sql, @ par, @ filename EXECUTE master..xp_cmdshell??': / 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)