Results 1 to 2 of 2

Thread: Select INSERT in c#

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Select INSERT in c#

    Hello There,

    I just wanna ask how will i implement Select Insert query in C#.

    Example

    "INSERT INTO DB1.TABLE1 (lastname,firstname,middlename) SELECT lastname,firstname,middlename FROM DB2.TABLE2"

    can i use this query like this?or do i need to separate the two statements.
    cmd.commandtext = "INSERT INTO DB1.TABLE1 (lastname,firstname,middlename) SELECT lastname,firstname,middlename FROM DB2.TABLE2";

    Thanks in advance!
    glen

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Select INSERT in c#

    Initially my reaction was... yes, yes you can... the insert syntax allows for the use of a select statement for the source of the data to insert...that's inherent in SQL. It's part of the language.

    Then I noticed you're using two different databases.

    Two things - first, this is more of a database question, the fact that you're using C# doesn't really play into this. I'll ask a mod to move it.
    Secondly, the question really is "how to select data from one database to insert into another database"... and the answer depends on what database system (SQL Server, Access, MySQL, Oracle, etc) ... so we'll need to know that before moving on.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width