DECLARE @rowc int DECLARE @j INT=1 SET @rowc= (SELECT COUNT(1) FROM [AdventureWorks2014].[Sales].[SalesOrderDetail] WITH(NOLOCK)) --121317 WHILE (@rowc>0) BEGIN PRINT @j INSERT INTO [Sales].[SalesOrderDetail_YEDEK] SELECT TOP 100 [SalesOrderID], [SalesOrderDetailID], [CarrierTrackingNumber], [OrderQty], [ProductID], [SpecialOfferID], [UnitPrice], [UnitPriceDiscount], [LineTotal], [rowguid], [ModifiedDate] FROM Sales.SalesOrderDetail WHERE SalesOrderDetailID>=@j AND SalesOrderDetailID<@j+100 SET @j=@j+100 SET @rowc = @rowc-100 END