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. Database & SysAdmin
  3. Database
  4. SQL Copy Table in C#

SQL Copy Table in C#

Scheduled Pinned Locked Moved Database
databasecsharphelpquestion
4 Posts 4 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.
  • B Offline
    B Offline
    bxlorenz
    wrote on last edited by
    #1

    I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks

    L N P 3 Replies Last reply
    0
    • B bxlorenz

      I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks

      L Offline
      L Offline
      loyal ginger
      wrote on last edited by
      #2

      This may be what you are looking for: http://69.10.233.10/KB/database/GenericCopyTableDataFcn.aspx[^] I used his solution in my project. It worked well. Happy programming!

      1 Reply Last reply
      0
      • B bxlorenz

        I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        Solution 1: Take the help of

        SSIS

        for the task. It is handy and simple. Solution 2: Using

        SMO class

        , you can create a backup of your database and restore it also. There are plenty of articles in the net explaining how to do the same using SMO. Please have a look Backup and restore SQL databases[^] Hope this helps :)

        Niladri Biswas

        1 Reply Last reply
        0
        • B bxlorenz

          I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks

          P Offline
          P Offline
          Paul Voicu
          wrote on last edited by
          #4

          Try using SqlBulkCopy - google for that and check out the example here http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server[^]

          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