Author |
Topic |
omsec
Starting Member
4 Posts |
Posted - 2006-12-24 : 11:45:41
|
Yep, it's me again :-)I have two Tabels, that look similar but not exactly the same. I wonder, what is the best way to copy a record from one Table to another. I tried something like this, which did not work:insert into cmif_h(Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate)values(select Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate from cmif where Mandant = 5 and AppID = 403220766) My Idea: I thought if I provide a result set that contains the same fields in the same order as specified in the INSERT INTO statement I could archive some "on-the-fly" copy operation.Thanks in Advance - Roger |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-12-24 : 12:23:50
|
you can do this:insert into cmif_hselect Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate from cmifwhere Mandant = 5 and AppID = 403220766 www.elsasoft.org |
 |
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2006-12-24 : 12:38:48
|
I guess my question is "Why do you need identical data in two different tables"? Kinda goes against the idea of a database, in general.--Jeff Moden |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-24 : 23:13:57
|
quote: Originally posted by omsec Yep, it's me again :-)I have two Tabels, that look similar but not exactly the same. I wonder, what is the best way to copy a record from one Table to another. I tried something like this, which did not work:insert into cmif_h(Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate)values(select Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate from cmif where Mandant = 5 and AppID = 403220766) My Idea: I thought if I provide a result set that contains the same fields in the same order as specified in the INSERT INTO statement I could archive some "on-the-fly" copy operation.Thanks in Advance - Roger
You shouldnt use Values when you do Insert into ..Select insert into cmif_h(Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate)select Mandant, AppID, CUser, CDate, MUser, MDate, IUser, IDate, FUser, FDate from cmif where Mandant = 5 and AppID = 403220766 MadhivananFailing to plan is Planning to fail |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-24 : 23:17:07
|
quote: Originally posted by Jeff Moden I guess my question is "Why do you need identical data in two different tables"? Kinda goes against the idea of a database, in general.--Jeff Moden
I think it is just for practice to a newbie MadhivananFailing to plan is Planning to fail |
 |
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-12-25 : 02:23:06
|
quote: Originally posted by Jeff Moden I guess my question is "Why do you need identical data in two different tables"? Kinda goes against the idea of a database, in general.--Jeff Moden
Aha just a guess may be for Audit Trailing purpose Chiraghttp://chirikworld.blogspot.com/ |
 |
|
omsec
Starting Member
4 Posts |
Posted - 2006-12-25 : 05:13:03
|
Thank You.Indeed, I am looking for a way to implement (DB-) Server-side auditing. And I want to avoid SQL-Code in my C#-Application, mostly due to performance and security thoughts. |
 |
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
|
|
|
|