Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-15 : 10:42:07
|
| I'm trying to perform an insert on a table from another table, butthe fieldnames are different. The data is similar, but there areless fields as well. Does anyone know how to accomplish this? Allthe material I've read on the Internet so far pertaining to Insertstatements, has all the column names matching up.Any help would be greatly appreciated. |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-02-15 : 10:44:06
|
| Insert Into TableDestination (Filed_A, Field_B, Field_C)Select Field_X, Field_Y, Field_Z From TableSourceSpecify the source & destination Fileds in the proper orderie. Field_X data to be inserted to Field_AField_Y data to be inserted to Field_BField_Z data to be inserted to Field_CIt doesn't matter TableDestination has more fields as Filed_D, Filed_E ...TableSource has more fields as Filed_U, Filed_V ...Field_A name being different from Field_Xas long as the corresponding fields match in data type |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-15 : 10:47:36
|
| Thank you so much for the quick reply :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-16 : 00:58:49
|
| Also note that data types should match with respective columnsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|