>start = SECONDS() >Local loCursor, lcConStr > >lcConStr = 'Provider=SQLNCLI11.0;Trusted_connection=Yes;Server=.\SQLExpress;Database=Sampledb' >loCursor = Createobject('CaGeneric',m.lcConStr) > >With loCursor > .Alias = 'myTable' > TEXT TO .SelectCmd noshow >SELECT * FROM hugeTable > ENDTEXT >Endwith >If loCursor.QueryFill() > Select (loCursor.Alias) > Browse LAST nowait >Endif >? SECONDS()-m.start >Define Class CaGeneric As CursorAdapter > CompareMemo = .F. > FetchAsNeeded = .T. > FetchSize = 100 > FetchMemo = .T. > BatchUpdateCount = 100 > WhereType = 1 > AllowSimultaneousFetch = .T. > MapVarchar = .T. > MapBinary = .T. > BufferModeOverride = 5 > > DataSourceType = 'ADO' > InsertCmdDataSourceType = 'ADO' > UpdateCmdDataSourceType = 'ADO' > DeleteCmdDataSourceType = 'ADO' > > Procedure Init(tcConnectionString) > Set Multilocks On > Local loConnDataSource > loConnDataSource = Createobject('ADODB.Connection') > loConnDataSource.ConnectionString = m.tcConnectionString > loConnDataSource.Open() > This.Datasource = Createobject('ADODB.RecordSet') > This.Datasource.CursorLocation = 3 && adUseClient > This.Datasource.LockType = 3 && adLockOptimistic > This.Datasource.ActiveConnection = m.loConnDataSource > loCommand = Createobject('ADODB.Command') > loCommand.ActiveConnection = loConnDataSource > This.AddProperty('oCommand',loCommand) > Store loCommand To ; > This.UpdateCmdDataSource,; > This.InsertCmdDataSource,; > This.DeleteCmdDataSource > Endproc > > Procedure MakeUpdatable(tcTableName,tckeyField,tlDoNotIncludeKey) > This.Tables = m.tcTableName > This.KeyFieldList = m.tckeyField > Local ix, lnUpdateableFCount > lnUpdateableFCount = Fcount(This.Alias)-Iif(This.DataSourceType='ADO',1,0) && last one is ADOBOOKMARK > For ix = 1 To m.lnUpdateableFCount > If !m.tlDoNotIncludeKey Or !(Upper(Field(m.ix,This.Alias,0)) == Upper(m.tckeyField)) > This.UpdatableFieldList = This.UpdatableFieldList + ; > IIF(Empty(This.UpdatableFieldList),'',',') + ; > FIELD(m.ix,This.Alias,0) > Endif > This.UpdateNameList = This.UpdateNameList + ; > IIF(Empty(This.UpdateNameList),'',',') + ; > TEXTMERGE('<<FIELD(m.ix,this.Alias,0)>> <<m.tcTableName>>.<<FIELD(m.ix,this.Alias,0)>>') > Endfor > Endproc > > Procedure QueryFill() > Local llSuccess > If This.DataSourceType ="ADO" > llSuccess = This.CursorFill(.F.,.F.,0,This.oCommand) > Else > llSuccess = This.CursorFill(.F.) > Endif > If !m.llSuccess > If This.DataSourceType ="ADO" > lcMessage = This.oCommand.CommandText + Chr(13) + This.GetErrorExplanation() > Else > lcMessage = This.GetErrorExplanation() > Endif > Messagebox(m.lcMessage) > Endif > Return m.llSuccess > Endproc > > Procedure GetErrorExplanation > Local lcError,ix > Local Array aWhy[1] > Aerror(aWhy) > lcError = "" > For ix = 1 To 7 > lcError = m.lcError + Transform(aWhy[m.ix]) + Chr(13) > Endfor > Return m.lcError > Endproc >Enddefine >>
>WITH TALLY AS >( >select top(10000) row_number() over (order by t1.object_id) as N >from sys.all_columns t1 cross join sys.all_columns t2 >) >SELECT tally.N as grp, c.* >into hugeTable >FROM nORTHWIND..CUSTOMERS C >CROSS JOIN tally; >Thanks a lot, this is indeed the way to go.