title: passing cursor variable into a query
body: <p>I am an Oracle developer trying to learn T-SQL.
  I have a table with one column in it (<code>table_name</code>). I need to be able to loop over all rows and find all columns for a given table. Then I need to output the result of it to the file.
  In Oracle it is pretty simple by using cursor in this fashion:</p>
  
  <pre><code>cursor my_curr is select table_name from my_table;
  for x in my_curr loop
     select column_name from user_tab_columns
     where table_name = x.table_name;
  
     utl_file ..... (writing result to an OS file)
  end loop;
  </code></pre>
  
  <p>What is the equivalent of the above in T-SQL? How would I use cursor variable to pass it into the query?</p>
  
  <p>Thanks,
  Eugene</p>