B
Beginner
Hi!
Does anyone know, why SQL automatically sorts when it is used to get data
from a table to another? Sorting is from 1 to z, and the GWh table is empty
when I run the sub.
Dim strSql As String
strSql = "INSERT INTO GWh(Id, Region, P_s) SELECT Id, Region, P_s FROM
Sopimustaulu;"
DoCmd.RunSQL (strSql)
The same thing happens when using two recordsets:
Dim rs As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
rs.Open "Sopimustaulu", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
rs2.Open "GWh", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While rs.EOF = False
rs2.AddNew
rs2![Id] = rs![Id]
rs2![Region] = rs![Region]
rs2![P_s] = rs![P_s]
rs2.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
rs2.Close
Set rs2 = Nothing
Is there any way to turn the automatic sorting off? I'd like to use SQL for
this, because it is several seconds faster than using recordsets.
Does anyone know, why SQL automatically sorts when it is used to get data
from a table to another? Sorting is from 1 to z, and the GWh table is empty
when I run the sub.
Dim strSql As String
strSql = "INSERT INTO GWh(Id, Region, P_s) SELECT Id, Region, P_s FROM
Sopimustaulu;"
DoCmd.RunSQL (strSql)
The same thing happens when using two recordsets:
Dim rs As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
rs.Open "Sopimustaulu", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
rs2.Open "GWh", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While rs.EOF = False
rs2.AddNew
rs2![Id] = rs![Id]
rs2![Region] = rs![Region]
rs2![P_s] = rs![P_s]
rs2.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
rs2.Close
Set rs2 = Nothing
Is there any way to turn the automatic sorting off? I'd like to use SQL for
this, because it is several seconds faster than using recordsets.