title: TSQL - perform code for each row of an select
body: <p>Is it possible somehow to execute some code for each row of an select without using a cursor?</p>
  
  <p>In my case:
  I'm having a temp table to store some data for a complexe script. At the end i want to pint some informations of this table (limited by some conditions) to the output.</p>
  
  <p>Currently I'm using a cursor with a select to limit the rows of the table. In this cursor I'm using </p>
  
  <pre><code> print '...'
  </code></pre>
  
  <p>to generate the output.</p>
  
  <p>There must be an easier way to do such things...</p>
  
  <p>edit:</p>
  
  <pre><code>create table #tmpAttributes(AttributeId uniqueidentifier, Value float, ValueString nvarchar(max), ActionId uniqueidentifier)
  
  insert into #tmpAttributes (AttributeId, Value, ValueString, ActionId)
      select ID,..... -- in this select i'm doing some value conversions, if conversion is not possible i'm using -1
  
  insert into ActionAttribute (ActionDefinitionID, Discriminator, ID, ReferredActionID, ValueDate, ValueListID, ValueMoney, ValueString, ValueUserID)
      select @defId, 'ActionAttributeMoneyEntity', NEWID(), ActionId, null, null, Value, null, null from #tmpAttributes
  
  -- afterwards there is this cursor where I'm printint all rows where Value = -1
  </code></pre>