I work on SQL server 2012
I have temp table get data from excel and based on data exist on excel i insert on table inside loop
temp table always have big amount of data may be at least 5000 or 10000 or 15000 or more
I need every iteration increased by 5000 rows insert from temp table
so that i need best solutions for that according to speed and memory like that
and if there are any thing not correct as logic please tell me
my Query as below :
SQL
DECLARE@MaxValueint=(selectMax(DocumentPartID)from#Temp)DECLARE@Currentindexint=0DECLARE@Rows[dbo].[Type_ValidationInPut];while@Currentindex<@MaxValuebeginDELETE@RowsINSERTINTO@Rows(RowNumber,GivenPartNumber,GivenManufacturer)selectTOP5000DocumentPartID,isnull(AffectedProduct,''),isnull(CompanyName,'')FROM#Tempwhere(CategoryID=517884orCategoryID=...<