title: Inserting n number of records with T-SQL
body: <p>I want to add a variable number of records in a table (days)</p>
  
  <p>And I've seen a neat solution for this:</p>
  
  <pre><code>SET @nRecords=DATEDIFF(d,'2009-01-01',getdate())
  SET ROWCOUNT @nRecords
  INSERT int(identity,0,1) INTO #temp FROM sysobjects a,sysobjects b
  SET ROWCOUNT 0
  </code></pre>
  
  <p>But sadly that doesn't work in a UDF (because the #temp and the SET ROWCOUNT). Any idea how this could be achieved?</p>
  
  <p>At the moment I'm doing it with a WHILE and a table variable, but in terms of performance it's not a good solution.</p>