Infinite Loop while importing Excel to SQL -
i have code
use [database] set ansi_nulls on go set quoted_identifier on go alter procedure [dbo].[getdataexcel] declare c cursor select box, code , validity openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\barcodes.xlsx;hdr=yes', 'select box, code , validity [sheet1$]') declare @code bigint declare @box bigint declare @validity date begin open c fetch next c @box,@code,@validity while @@fetch_status = 0 begin insert cards (box, barcode, validitydate) select box, code , validity openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\barcodes.xlsx;hdr=yes', 'select box, code , validity [sheet1$]') fetch next c @box,@code,@validity end close c deallocate c end
while exporting table "cards" empty rows copied table , process doesn't stop , loop goes on , on , process restarted on , over, query doesn't stop executing unless stop , when see content of table , see null values of empty rows , filled rows' values , , repeated , how stop query reading empty rows , stop reading excel file on , on ?
why not use instead of cursor
insert (box, barcode, validitydate) select * openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\barcodes.xlsx;hdr=yes', 'select box, code, validity [sheet1$]')
Comments
Post a Comment