use master
go
declare @pr int,
	@str	varchar(1000)
Select @pr = (select top 1 spid from master..sysprocesses where dbid=db_id('ks'))
WHILE @pr is not null
BEGIN
	SET @str = 'kill '+STR(@pr)
	EXEC(@str)
	Select @pr = (select top 1 spid from master..sysprocesses where dbid=db_id('ks'))
END
go

restore database ks from disk='c:\backup\ks\ks2005.bak'
	with move 'ks_dat' to 'c:\program files\microsoft sql server\mssql\data\ks_dat.mdf',
	move 'ks_log' to 'c:\program files\microsoft sql server\mssql\data\ks_log.ldf',replace
go
