Reading last Row in Excel while importing - SQL Database -
i have following code imports excel data table , updates parameters , unable read rows , last row being read , want able read rows , update values in table
declare c cursor select barcode,msisdn,pos,[sim card number],[date of sale] openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\activatedcards.xlsx;hdr=yes', 'select barcode,msisdn,pos,[sim card number],[date of sale] [sheet1$]') declare @barcode bigint declare @msisdn bigint declare @pos nvarchar(50) declare @simcardnb bigint declare @activateddate date begin open c fetch next c @barcode,@msisdn,@pos,@simcardnb,@activateddate while @@fetch_status = 0 begin select @barcode=barcode,@msisdn=msisdn,@pos=pos,@simcardnb=[sim card number],@activateddate=[date of sale] openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\activatedcards.xlsx;hdr=yes', 'select barcode,msisdn,pos,[sim card number],[date of sale] [sheet1$]') barcode <> '' update cards set msisdn=@msisdn , possold=@pos, activated=1, simcardnb=@simcardnb, activateddate=@activateddate, importdate=getdate(), collectiondeadlinedate=dateadd(day,30,importdate) cards.barcode=@barcode fetch next c @barcode,@msisdn,@pos,@simcardnb,@activateddate end close c deallocate c
use npoi api read/write xls, doc, ppt files. microsoft microsoft.ace.oledb.12.0' built in api not task.
easy use , productive example can found following under.
Comments
Post a Comment