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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. LINQ
  4. SELECT INTO or CREATE TABLE

SELECT INTO or CREATE TABLE

Scheduled Pinned Locked Moved LINQ
databasequestioncsharphelp
5 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.
  • B Offline
    B Offline
    bxlorenz
    wrote on last edited by
    #1

    I have a SQL 2005 database and a SQL 2008 database. I want a simple SQL statement that will create/copy a table and its contents from 2005 into 2008 that I can use in a C# program. I know I can export using Mgmt Studio but I want to do in a a program. I am able to perform a SELECT INTO [MyDatabase2].[dbo].[mytable] SELECT * FROM [Mydatabase1].[dbo].[mytable] when they exist in different databases in the same machine and only in the same Database Instance but how do I across multiple instances or multiple machines. Can anyone help ? Thanks

    N T 2 Replies Last reply
    0
    • B bxlorenz

      I have a SQL 2005 database and a SQL 2008 database. I want a simple SQL statement that will create/copy a table and its contents from 2005 into 2008 that I can use in a C# program. I know I can export using Mgmt Studio but I want to do in a a program. I am able to perform a SELECT INTO [MyDatabase2].[dbo].[mytable] SELECT * FROM [Mydatabase1].[dbo].[mytable] when they exist in different databases in the same machine and only in the same Database Instance but how do I across multiple instances or multiple machines. Can anyone help ? Thanks

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      bxlorenz wrote:

      I can use in a C# program.

      Why would you want to do this in C#? Why use in-line SQL statement X| You'd be better off writing an SSIS package or at least a stored procedure. You also need create the linked servers in your SQL instance to go between machines and instances. BTW, this has nothing to do with Linq, why did you choose this forum rather then the Database forum?


      only two letters away from being an asset

      B 1 Reply Last reply
      0
      • N Not Active

        bxlorenz wrote:

        I can use in a C# program.

        Why would you want to do this in C#? Why use in-line SQL statement X| You'd be better off writing an SSIS package or at least a stored procedure. You also need create the linked servers in your SQL instance to go between machines and instances. BTW, this has nothing to do with Linq, why did you choose this forum rather then the Database forum?


        only two letters away from being an asset

        B Offline
        B Offline
        bxlorenz
        wrote on last edited by
        #3

        Well, I already have a C# program that connects to the databases on different systems to perform some conversions of data from different tables which are not same structure. However I do have several tables that are identical and want to just create and copy entire data over as well. I know I could create the table and then perform select and insert, I just want a simple was to perform all at once without haiving to read the table and then the columns and create a new table based off it. Not familiar with SSIS packacge and linking servers. Again just looking to convert data over from one system to another based on certain data selected, but preserve some tables as is. thnx

        1 Reply Last reply
        0
        • B bxlorenz

          I have a SQL 2005 database and a SQL 2008 database. I want a simple SQL statement that will create/copy a table and its contents from 2005 into 2008 that I can use in a C# program. I know I can export using Mgmt Studio but I want to do in a a program. I am able to perform a SELECT INTO [MyDatabase2].[dbo].[mytable] SELECT * FROM [Mydatabase1].[dbo].[mytable] when they exist in different databases in the same machine and only in the same Database Instance but how do I across multiple instances or multiple machines. Can anyone help ? Thanks

          T Offline
          T Offline
          Thanigainathan S
          wrote on last edited by
          #4

          Well you should be using SqlBulk Copy Command[^]

          India is Mythical and so we are

          B 1 Reply Last reply
          0
          • T Thanigainathan S

            Well you should be using SqlBulk Copy Command[^]

            India is Mythical and so we are

            B Offline
            B Offline
            bxlorenz
            wrote on last edited by
            #5

            So what would be the exact syntax if I am connecting to two different Systems running SQL 2005 and 2008 and using to different instances and databases ? Thanks

            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