Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. fastest way to copy a table to a new table

fastest way to copy a table to a new table

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hounetdev
    wrote on last edited by
    #1

    Hello, Ok, I have a table with alot of accounts and I want to copy only the accounts for a month at a time to a new table. what is the fastest and best way to do this there are like 400,000 accounts that are going to be copied and i have to only copy accounts between the startdate and enddate that the user picks from date pickers. I am using vb.net and access as the datebase. Another problem is that the date in the original table is not in a standard format 1/1/2004 it is in a Timestamp which is time since 1/1/1900 and it lookes something like this 54745186 so i have to format it before i can check it against the dates the user enters. The way i am doning it know is like this, if anyone can suggest a faster way, cause this is taking like 10 mins. MDRDataAdapter.SelectCommand.CommandText = "Select RecID,Format([mCallEnd]![Timestamp]/1440+1,""ddddd""), Call,Account,Billing,Client,OrgAccount, Duration,Port,Initials,CallKind,OpTime From mCallEnd" MDRDataSet.Clear() MDRDataAdapter.Fill(MDRDataSet) For i = 0 To MDRDataSet.Tables("mCallEnd").Rows.Count - 1 tempdate = MDRDataSet.Tables("mCallEnd").Rows(i).Item("Expr1001") If tempdate >= startdate And tempdate < enddate Then NewMDRdap.InsertCommand.CommandText = "insert into newtable (RecID,[Timestamp],Call,Account,Billing,Client,OrgAccount, Duration,Port,Initials,CallKind,OpTime) values MDRDataSet.Tables("mCallEnd").Rows(i).Item("RecID") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Expr1001") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Call") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Account") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Billing") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Client") MDRDataSet.Tables("mCallEnd").Rows(i).Item("OrgAccount") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Duration") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Port") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Initials") MDRDataSet.Tables("mCallEnd").Rows(i).Item("CallKind") MDRDataSet.Tables("mCallEnd").Rows(i).Item("OpTime")) NewMDRdap.InsertCommand.ExecuteNonQuery() End If Next

    D R 2 Replies Last reply
    0
    • H hounetdev

      Hello, Ok, I have a table with alot of accounts and I want to copy only the accounts for a month at a time to a new table. what is the fastest and best way to do this there are like 400,000 accounts that are going to be copied and i have to only copy accounts between the startdate and enddate that the user picks from date pickers. I am using vb.net and access as the datebase. Another problem is that the date in the original table is not in a standard format 1/1/2004 it is in a Timestamp which is time since 1/1/1900 and it lookes something like this 54745186 so i have to format it before i can check it against the dates the user enters. The way i am doning it know is like this, if anyone can suggest a faster way, cause this is taking like 10 mins. MDRDataAdapter.SelectCommand.CommandText = "Select RecID,Format([mCallEnd]![Timestamp]/1440+1,""ddddd""), Call,Account,Billing,Client,OrgAccount, Duration,Port,Initials,CallKind,OpTime From mCallEnd" MDRDataSet.Clear() MDRDataAdapter.Fill(MDRDataSet) For i = 0 To MDRDataSet.Tables("mCallEnd").Rows.Count - 1 tempdate = MDRDataSet.Tables("mCallEnd").Rows(i).Item("Expr1001") If tempdate >= startdate And tempdate < enddate Then NewMDRdap.InsertCommand.CommandText = "insert into newtable (RecID,[Timestamp],Call,Account,Billing,Client,OrgAccount, Duration,Port,Initials,CallKind,OpTime) values MDRDataSet.Tables("mCallEnd").Rows(i).Item("RecID") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Expr1001") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Call") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Account") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Billing") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Client") MDRDataSet.Tables("mCallEnd").Rows(i).Item("OrgAccount") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Duration") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Port") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Initials") MDRDataSet.Tables("mCallEnd").Rows(i).Item("CallKind") MDRDataSet.Tables("mCallEnd").Rows(i).Item("OpTime")) NewMDRdap.InsertCommand.ExecuteNonQuery() End If Next

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      ACCESS?? 400,000 records in ACCESS?? Uhhh... Access is a desktop database. It was not designed for this kind of volume. Your not going to be able to speed this up very much at all since it works entirely in files. SQL Server is MUCH better at handling this kind of volume. If you really want to speed this up, migrate the database to SQL Server or even the MSDE first. In Access 2003, use the Upsizing Wizard... And why would you copy all the records for a month into a new table? If you are looking to speed up future queries on that new table, the time your save then is only going to be eaten up by copying everything to a new table first. So in the end, your not really saving that much time... RageInTheMachine9532

      1 Reply Last reply
      0
      • H hounetdev

        Hello, Ok, I have a table with alot of accounts and I want to copy only the accounts for a month at a time to a new table. what is the fastest and best way to do this there are like 400,000 accounts that are going to be copied and i have to only copy accounts between the startdate and enddate that the user picks from date pickers. I am using vb.net and access as the datebase. Another problem is that the date in the original table is not in a standard format 1/1/2004 it is in a Timestamp which is time since 1/1/1900 and it lookes something like this 54745186 so i have to format it before i can check it against the dates the user enters. The way i am doning it know is like this, if anyone can suggest a faster way, cause this is taking like 10 mins. MDRDataAdapter.SelectCommand.CommandText = "Select RecID,Format([mCallEnd]![Timestamp]/1440+1,""ddddd""), Call,Account,Billing,Client,OrgAccount, Duration,Port,Initials,CallKind,OpTime From mCallEnd" MDRDataSet.Clear() MDRDataAdapter.Fill(MDRDataSet) For i = 0 To MDRDataSet.Tables("mCallEnd").Rows.Count - 1 tempdate = MDRDataSet.Tables("mCallEnd").Rows(i).Item("Expr1001") If tempdate >= startdate And tempdate < enddate Then NewMDRdap.InsertCommand.CommandText = "insert into newtable (RecID,[Timestamp],Call,Account,Billing,Client,OrgAccount, Duration,Port,Initials,CallKind,OpTime) values MDRDataSet.Tables("mCallEnd").Rows(i).Item("RecID") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Expr1001") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Call") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Account") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Billing") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Client") MDRDataSet.Tables("mCallEnd").Rows(i).Item("OrgAccount") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Duration") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Port") MDRDataSet.Tables("mCallEnd").Rows(i).Item("Initials") MDRDataSet.Tables("mCallEnd").Rows(i).Item("CallKind") MDRDataSet.Tables("mCallEnd").Rows(i).Item("OpTime")) NewMDRdap.InsertCommand.ExecuteNonQuery() End If Next

        R Offline
        R Offline
        Randy S
        wrote on last edited by
        #3

        I'm not sure why you want to pull the entire months of tables data. I suspect that the data set will take some time to fill. You could try a paramtized query. Only fill the dataset withthe requested row. The difference is you would add "Where RecID = ? ". Your form would then have a text box for the user to enter an ID and a button to retrieve the data. Is this something that you could use?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups