这里是批处理命令-----备份的
delete d:restorecw_ft.bak
delete d:restorecw_sd.bak
sqlcmd -i "bak.sql"
这是sqlcmd 备份的
:connect .
BACKUP DATABASE cw_ft TO DISK = 'd:
estorecw_ft.bak' WITH INIT
go
BACKUP DATABASE cw_sd TO DISK = 'd:
estorecw_sd.bak' WITH INIT
go
这是批处理---恢复的
sqlcmd -i "restore.sql"
这是sqlcmd 恢复的
:connect .
USE master
GO
ALTER DATABASE [cw_ft] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
--查看是否还有用户连接
--SELECT * FROM sys.[sysprocesses] WHERE DB_NAME([dbid])='cw_ft'
--GO
ALTER DATABASE [cw_ft] SET MULTI_USER
GO
RESTORE DATABASE [cw_ft] FROM DISK = N'd:
estorecw_ft.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
go
ALTER DATABASE [cw_sd] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
--查看是否还有用户连接
--SELECT * FROM sys.[sysprocesses] WHERE DB_NAME([dbid])='cw_sd'
--GO
ALTER DATABASE [cw_sd] SET MULTI_USER
GO
RESTORE DATABASE [cw_sd] FROM DISK = N'd:
estorecw_sd.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
go