server| Backup | server | data | database
/* data stored in storage process * *
/**//* support from the data from the service device to the local machine
--
CREATE PROCEDURE Up_dbbackup
(
@backup_db_name VARCHAR (128),
@filename VARCHAR (128),/**//* backup path + filename * *
@flag VARCHAR () OUTPUT
)
As
SET NOCOUNT on
DECLARE @sql NVARCHAR (4000), @par NVARCHAR (1000)
IF not EXISTS (
SELECT * FROM Master. sysdatabases
WHERE name= @backup_db_name
)
BEGIN
SELECT @flag = ' data library ' + @backup_db_name + ' does not exist! '
Return
End
ELSE
BEGIN
IF Right (@filename, 1) <> ' and CHARINDEX (' \ ', @filename) <>0
BEGIN
/**//* definition of the logo
DECLARE @lFlag INT
EXECUTE @lFlag =master. xp_cmdshell ' DIR Z: '
IF @lFlag <>0
BEGIN
/**//* a fully shared catalogue of DB on the client 192.168.2.45, specifying a username and password. Win98 user name and password not required
EXECUTE @lFlag =master. xp_cmdshell ' NET use Z: \\192.168.2.45\db$ test/user:ca.atc\test '
IF @lFlag <>0
BEGIN
SELECT @flag = ' Service creators fail! '
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 '
SELECT @flag = ' data library ' + @backup_db_name + ' backup success! '
Return
End
ELSE
BEGIN
SELECT @flag = ' data is in the library's path wrong! '
Return
End
End
* * The above process is tested under SQL Server