-
Nov 15th, 2012, 11:58 AM
#1
Thread Starter
Addicted Member
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
-
Nov 15th, 2012, 12:08 PM
#2
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|