title: Check one table values with another and then insert to table
body: <p>have 2 tables for example lets call one - <strong>names</strong> , second - <strong>age</strong></p>
  
  <pre><code>names table :                   age table :
  ID      Names               ID      Names    Age
  1       Bob                  1      Bob      18
  2       Tommy                2      Tommy    21
  3       Kate                 3      Kate     20
  4       Adam                 4      Adam     23
  5       Karl                 5      Karl     25
  </code></pre>
  
  <p>in stored procedure want check if name from names table exists in age table </p>
  
  <pre><code>create table #tbl
  (
    id int identity(1,1),
    age int
  )
  
  insert into #tbl (age) values(and hear each age for each name)
  </code></pre>
  
  <p>I think i need some loop for doing it without cursor but how ? please help me </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I solve it like :</p>
  
  <pre><code>create table #tbl 
  (
    id int identity(1,1),
    age int
  );
  
  INSERT INTO #tbl (age) 
  SELECT a.age
    FROM age a
   WHERE NOT EXISTS (
     SELECT n.name
     FROM names n
     WHERE a.Name = n.Name)
  
     select * from #tbl 
  </code></pre>