use master
go
declare @start int ,
@end int ,
@spid1 int ,
@AA NVARCHAR(15)
select @start=0
select @end = (select count(*) from sysprocesses where dbid=db_id('ABC'))
select @spid1 = (select min(spid) from sysprocesses where dbid=db_id('ABC'))
while @start <= @end
begin
SELECT @AA='KILL '+ CONVERT(VARCHAR(4),@SPID1)
exec sp_executesql @aa
select @spid1 = (select min(spid) from sysprocesses where dbid=db_id('ABC') and spid > @spid1)
SELECT @START=@START+1
end
restore database ABC from ABCDUMP with
move 'ABC_Data' to 'D:\Program Files\Microsoft SQL Server\MSSQL\Data\ABC\ABC_Data.MDF',
move 'ABC_Log' to 'D:\Program Files\Microsoft SQL Server\MSSQL\Data\ABC\ABC_Log.LDF',replace
go
declare @start int ,
@end int ,
@spid1 int ,
@AA NVARCHAR(15)
select @start=0
select @end = (select count(*) from sysprocesses where dbid=db_id('ABC'))
select @spid1 = (select min(spid) from sysprocesses where dbid=db_id('ABC'))
while @start <= @end
begin
SELECT @AA='KILL '+ CONVERT(VARCHAR(4),@SPID1)
exec sp_executesql @aa
select @spid1 = (select min(spid) from sysprocesses where dbid=db_id('ABC') and spid > @spid1)
SELECT @START=@START+1
end
restore database ABC from ABCDUMP with
move 'ABC_Data' to 'D:\Program Files\Microsoft SQL Server\MSSQL\Data\ABC\ABC_Data.MDF',
move 'ABC_Log' to 'D:\Program Files\Microsoft SQL Server\MSSQL\Data\ABC\ABC_Log.LDF',replace
No comments:
Post a Comment