Migration - Makes unavailable All or Selected the databases (Read-Only / OffLine)

DECLARE @name VARCHAR(50) -- database name  
DECLARE @strSQL NVARCHAR(200) -- used for file name
 
 
DECLARE db_cursor CURSOR READ_ONLY FOR  
SELECT name 
FROM master.dbo.sysdatabases 
WHERE (name like 'Fin%' 
or
       name = 'AutoApp'
or
      name = 'AutoApp_PRE'
or
      name = 'Address_DB'
or
      name like 'Emp%')
--WHERE name not IN ('master','model','msdb','tempdb')  -- exclude these databases
 
OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   
 
WHILE @@FETCH_STATUS = 0   
BEGIN   
 
   Exec DBA..sp_DBA_KillDB @name
 
   Set @strSQL = 'ALTER DATABASE '+ @name +' SET OFFLINE WITH ROLLBACK IMMEDIATE'
   
   EXECUTE sp_executesql @strSQL
 
   FETCH NEXT FROM db_cursor INTO @name   
END   
 
 
CLOSE db_cursor   
DEALLOCATE db_cursorDECLARE @name VARCHAR(50) -- database name  
DECLARE @strSQL NVARCHAR(200) -- used for file name
 
 
DECLARE db_cursor CURSOR READ_ONLY FOR  
SELECT name 
FROM master.dbo.sysdatabases 
WHERE (name like 'Fin%' 
or
       name = 'AutoApp'
or
      name = 'AutoApp_PRE'
or
      name = 'Address_DB'
or
      name like 'Emp%')
--WHERE name not IN ('master','model','msdb','tempdb')  -- exclude these databases
 
OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   
 
WHILE @@FETCH_STATUS = 0   
BEGIN   
 
   Exec DBA..sp_DBA_KillDB @name
 
   Set @strSQL = 'ALTER DATABASE '+ @name +' SET OFFLINE WITH ROLLBACK IMMEDIATE'
   
   EXECUTE sp_executesql @strSQL
 
   FETCH NEXT FROM db_cursor INTO @name   
END   
 
 
CLOSE db_cursor   
DEALLOCATE db_cursor