 <p>Merge the two insert into single insert like this</p> <pre><code>INSERT INTO @EventValueResultSet(....) SELECT .... .... FROM dbo.EventValue EV WITH (NOLOCK)) INNER JOIN dbo.DataRun_ DR WITH (NOLOCK) ON EV.dataRunId = DR.Id AND DR.PersonId = @PersonId WHERE PhysioCurrentDataTime BETWEEN @blockStartTime AND @endTime OR ( ( CurrentDataTime &lt; @blockStartTime ) AND ( EventEndTime = 0 OR EventEndTime &gt;= @blockStartTime ) ) </code></pre>