MS-SQL 디비복구
ALTER DATABASE 테이블명 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
-- 물론, 이 과정에서 현재 데이터베이스에 연결되어 있는 사용자의 연결이 모두 끊어지게 됩니다.
RESTORE DATABASE TEST FROM DISK = 'C:\TEMP\Test.bak'
전부다 쿼리분석기에서 치면 된다.. 상단의 restore 명령어가 성공적으로 수행되면 밑에껀 생략 ( 자동으로 됨)
ALTER DATABASE TEST SET MULTI_USER
restrore 명령어시 데이터베이스가 사용중이라고 나오면
sp_who2
해당 디비 죽이기 => kill 프로세스ID
그런 다음에 다시 restore~~~

댓글목록
슈퍼아이피님의 댓글
use master
declare @file1 Varchar(2000)
declare @file2 Varchar(2000)
declare @file3 Varchar(2000)
SET @file1 = 'G:\DONGBU_db_200908102302.BAK'
SET @file2 = 'G:\CL_DONGBU_db_200911052300.BAK'
SET @file3 = 'G:\CL_Dongbu2_db_200911052303.BAK'
alter database dongbu set single_user with rollback immediate
restore database DONGBU from disk=@file1
with move 'DONGBU_Data' to 'D:\Microsoft SQL Server\MSSQL\Data\Dongbu_data.mdf',
move 'DONGBU_Log' to 'D:\Microsoft SQL Server\MSSQL\Data\Dongbu_Log.ldf'
alter database dongbu set multi_user
alter database CL_DONGBU set single_user with rollback immediate
restore database CL_DONGBU from disk=@file2
with move 'CL_DONGBU_Data' to 'D:\Microsoft SQL Server\MSSQL\Data\CL_Dongbu_data.mdf',
move 'CL_DONGBU_Log' to 'D:\Microsoft SQL Server\MSSQL\Data\CL_Dongbu_Log.ldf'
alter database CL_DONGBU set multi_user
alter database CL_DONGBU2 set single_user with rollback immediate
restore database CL_DONGBU2 from disk=@file3
with move 'CL_DONGBU2_Data' to 'D:\Microsoft SQL Server\MSSQL\Data\CL_Dongbu2_data.mdf',
move 'CL_DONGBU2_Log' to 'D:\Microsoft SQL Server\MSSQL\Data\CL_Dongbu2_Log.ldf'
alter database CL_DONGBU2 set multi_user
use dongbu
exec sp_change_users_login 'Update_One','dongbuweb','dongbuweb'
exec sp_change_users_login 'Update_One','imgwf','imgwf'
use cl_dongbu
exec sp_change_users_login 'Update_One','dongbuweb','dongbuweb'
exec sp_change_users_login 'Update_One','imgwf','imgwf'
use cl_dongbu2
exec sp_change_users_login 'Update_One','dongbuweb','dongbuweb'
exec sp_change_users_login 'Update_One','imgwf','imgwf'