title: SQL Server error "SQL Server Sub query returned more than 1 value"
body: <pre><code>&lt;!-- if version --&gt;
  </code></pre>
  
  <p>query to change the recovery models and setup auto growth to 50 MB
  </p>
  
  <pre><code>USE MASTER   
  GO    
  SET QUOTED_IDENTIFIER ON  
  GO  
  SET ARITHABORT ON  
  GO  
  </code></pre>
  
  <p>
  Took all the DB's except system databases.
  </p>
  
  <pre><code>DECLARE @DBName NVARCHAR(255),@LogicalFileName NVARCHAR(255),@DBRecoveryDesc Varchar(200), @isql varchar(2000)
  
  DECLARE DatabaseList CURSOR   
  FOR   
  SELECT name,recovery_model_desc  
  FROM sys.databases  
  WHERE state_desc = 'ONLINE'  
  AND is_read_only = 0  
  and database_id&gt;4  
  ORDER BY name  
  </code></pre>
  
  <p>
  facing error near below subquery 
  </p>
  
  <pre><code>OPEN DatabaseList  
  FETCH NEXT FROM DatabaseList INTO @DBName,@DBRecoveryDesc  
  WHILE @@FETCH_STATUS = 0     
  BEGIN   
  SET @LogicalFileName=(SELECT name FROM sys.master_files AS mf WHERE DB_NAME(database_id)=@DBName and type_desc='log' ) 
  
  If @DBRecoveryDesc='Full'  
  Begin  
  select @isql = 'Use ['+@DBName+'] 
  ALTER DATABASE ['+@DBName+'] SET RECOVERY SIMPLE WITH NO_WAIT
  ALTER DATABASE ['+@DBName+'] MODIFY FILE (NAME = N'''+@LogicalFileName+''', FILEGROWTH = 50)'  
  </code></pre>
  
  <p>
  Script will give output script
  
      --exec(@isql) 
      print(@isql)
      END  </p>
  
  <pre><code>If @DBRecoveryDesc='Simple'  
  Begin   
  select @isql = 'Use ['+@DBName+'] 
  ALTER DATABASE ['+@DBName+'] MODIFY FILE (NAME = N'''+@LogicalFileName+''', FILEGROWTH = 50)' 
  
  --exec(@isql)
  print(@isql)
  END
  FETCH NEXT FROM DatabaseList INTO @DBName,@DBRecoveryDesc
  END  
  CLOSE DatabaseList  
  DEALLOCATE DatabaseList
  </code></pre>
  
  <p>
  Please help me to change the sub query details 
  </p>