title: How do I avoid the "Subquery returned more than 1 value" report?
body: <p>I wrote the following script:</p>
  
  <pre><code>IF OBJECT_ID('tempdb..#Temp') IS NOT NULL
  DROP TABLE #Temp
  create table #Temp
  (
          [KeyName] [nvarchar](max),
          [CertName] [nvarchar](max),
  )
  Go
  
  
  INSERT INTO #Temp
  EXEC fetch_data
  
  GO
  
  IF(Select #Temp.KeyName From #Temp) = 'SSN_Key_01' AND (Select CertName From 
  #Temp) = 'PasswordManager001'
  EXEC decrypt_1
  
  Else
  
  IF(Select KeyName From #Temp) = 'SSN_Key_02' AND (Select CertName From #Temp) 
  = 'PasswordManager002'
  EXEC decrypt_2
  
  Else
  
  IF(Select KeyName From #Temp) = 'SSN_Key_03' AND (Select CertName From #Temp) 
  = 'PasswordManager003'
  EXEC decrypt_3
  
  GO
  </code></pre>
  
  <p>and keep on getting the error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery is used as an expression.</p>
  
  <p>I simply try to do a little comparison on my returned values and execute them based on the three conditions visible on the script.</p>
  
  <p>Why do I keep getting the report?</p>