title: Teradata Insert Count into Variable
body: <p>Description what I am trying to do:</p>
  
  <p>I have 2 environments one has data (X) second one has no data (Y).</p>
  
  <p>I have done procedure which has input parameter P_TableName. It should check if in this table is any data and IF There is then we will take data to Y environment.</p>
  
  <p>So Mostly it works but I have problem with one freaking simple thing ( I have not much experience in TD but in Oracle it would be a 10seconds).</p>
  
  <p>I need to pass select count(*) from X to variable how to do that?.</p>
  
  <p>I was trying by SET VAR = SELECT...
  INSERT INTO VAR SELECT...
  I was trying to make a variable for statement which is directly executing </p>
  
  <pre><code>        SET v_sql_stmt = 'INSERT INTO ' || VAR|| ' SELECT COUNT(*) FROM ' || P_TableName;
          CALL DBC.SYSEXECSQL(v_sql_stmt);
  </code></pre>
  
  <p>It's probably really simple thing but I can't find good solution for that. Please help</p>