﻿USE master;

DECLARE @DatabaseName nvarchar(50)
SET @DatabaseName = N'{0}'

DECLARE @SQL varchar(max)

SELECT @SQL = COALESCE(@SQL,'') + ' BEGIN TRY Kill ' + Convert(varchar, SPId) + '; END TRY BEGIN CATCH END CATCH;'
FROM MASTER..SysProcesses
WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId

EXEC(@SQL)

RESTORE DATABASE {0} from 
DATABASE_SNAPSHOT = '{0}_Snapshot';