title: SQL CASE SELECT return char
body: <p>I have 6 tables: LS_CLIENT_INSEE_A, B, C , etc. Each table contains only 1 field: INSEE.</p>
  
  <p>I just want to know if my input exists in one of these tables and return the corresponding letter from the table name (A,B,C etc).</p>
  
  <p>Is there another why to rewrite this:</p>
  
  <pre><code>@TheInsee int
  AS
  BEGIN
  declare @Zone char(1)
  
  declare @CountA int
  declare @CountB int
  declare @CountC int
  declare @CountD int
  declare @CountF int
  declare @CountP int
  
  SELECT @CountA = COUNT(*) FROM LS_CLIENT_INSEE_A WHERE NO_INSEE = @TheInsee
  SELECT @CountB = COUNT(*) FROM LS_CLIENT_INSEE_B WHERE NO_INSEE = @TheInsee
  SELECT @CountC = COUNT(*) FROM LS_CLIENT_INSEE_C WHERE NO_INSEE = @TheInsee
  SELECT @CountD = COUNT(*) FROM LS_CLIENT_INSEE_D WHERE NO_INSEE = @TheInsee
  SELECT @CountF = COUNT(*) FROM LS_CLIENT_INSEE_F WHERE NO_INSEE = @TheInsee
  SELECT @CountP = COUNT(*) FROM LS_CLIENT_INSEE_P WHERE NO_INSEE = @TheInsee
  
  set @Zone = 
        CASE 
           WHEN @CountA &gt;  0   THEN 'A'
           WHEN @CountB &gt;  0   THEN 'B'
           WHEN @CountC &gt;  0   THEN 'C'   
           WHEN @CountD &gt;  0   THEN 'D' 
           WHEN @CountF &gt;  0   THEN 'F' 
           WHEN @CountP &gt;  0   THEN 'P'         
        END  
  
  END
  </code></pre>
  
  <p>Is above query the best way of achieving this?</p>
  
  <p>Thanks you in advance,
  Stev</p>