Speeding up an Insert TSQL procedure <p>I need some tip on tuning some TSQL to execute faster, it's taking way too long although it works. This may be because I'm fetching a key from another table before I can do the insert, any ideas anyone?</p> <pre><code>DECLARE db_cursorReads CURSOR FOR SELECT [MeterId] ,[MeterRead] FROM MdsReadsImports; declare @PremiseMeterId int; declare @MeterId nvarchar(24); declare @MeterRead int; OPEN db_cursorReads; FETCH NEXT FROM db_cursorReads INTO @MeterId ,@MeterRead; WHILE @@FETCH_STATUS = 0 BEGIN set @PremiseMeterId = (select top 1 PremiseMeterId from PremiseMeters where MeterId = @MeterId) insert into PremiseMeterReads (MeterRead,PremiseMeterId) values (@MeterRead, @MPremiseMeterId) FETCH NEXT FROM db_cursorReads INTO @MeterId ,@MeterRead; END; CLOSE db_cursorReads; DEALLOCATE db_cursorReads; </code></pre>