Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating SQL Server table
Message
From
09/03/2005 14:27:31
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
 
 
To
09/03/2005 12:10:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
Database:
MS SQL Server
Miscellaneous
Thread ID:
00994024
Message ID:
00994122
Views:
30
Cetin,

I tried setting buffering to 5 and 3 and used TABLEUPDATE() on my RV but that still took awhile. Although I am not sure if buffering set to 5 is any faster than 3.

At the beginning of my routine I first delete all the records in the SQL table with the following. The delete takes only a second for all 400,000 records.
lc_sql = [DELETE FROM mytable]
=SQLEXEC(mySqlConn, lc_sql)

Is there a way to do this with the VFP SQL-INSERT command?

Thanks,

Jerry

>
>1) If you use an updatable RV or SPT set buffering to 5.
>2) You can use "copy to myTransfer.txt type delimited" and bulk insert
>3) You can use DTS package
>4) You can use OpenRowSet() SQL server function
>
>Last one is one of the fastest I think. Below is partial class I've used for my own upsizing (fieldnames were same):
>
>* Sample
>oTransfer = CreateObject("SQLPutData")
>oTransfer.PutTheData()
>
>Define Class SQLPutData As Session
>	DataSession=2
>	DBPATH = Sys(5)+Curdir()+'myLocalDatabasePath'
>        LocalDBC = 'myLocalDatabase.dbc'
>	SQLDBNAME = "mySQLDatabase"
>	conHandle = .Null.
>
>	Procedure Init
>		This.conHandle = ;
>                Sqlstringconnect("Driver=SQL server;server=(local);Integrated Security=SSPI")
>		SQLExec(This.conHandle,"use ["+This.SQLDBNAME+"]")
>	Endproc
>
>	Procedure PutTheData
>		With This
>                   .GetDataFrom("[dbo].[mytable]","[field1],[field2],[field3]")
>                   SQLDisconnect(.conHandle)
>                endwith
>        endproc
>
>	Procedure GetDataFrom
>		Lparameters tcSQLName,tcFields
>		Local lcLocalTable, lcLocalFields, lcSQL, lnResult, ix, lcError
>		Local array arrErr[1]
>		lcLocalTable  = Justext(Chrtran(tcSQLName,'[]',''))
>		lcLocalFields = Chrtran(tcFields,'[]','')
>		Text to m.lcSQL textmerge noshow
>		insert into <<m.tcSQLName>>
>			SELECT <<m.tcFields>>
>			FROM OPENROWSET('VFPOLEDB',
>			'<<Addbs(this.DBPATH)+this.LocalDBC>>';'';'',
>			'select <<m.lcLocalFields>> from <<m.lcLocalTable>>')
>		endtext
>		lnResult = SQLExec(this.conHandle, m.lcSQL)
>		If m.lnResult < 0
>			AError(arrErr)
>			lcError = ''
>			For ix = 1 to Alen(arrErr)
>				lcError = lcError + Transform(arrErr[m.ix]) + Chr(13)	
>			EndFor
>			MessageBox(m.lcError)
>		Else
>			? m.tcSQLName
>		endif
>	Endproc
>enddefine
>
Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform