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 |
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2003-10-25 : 16:04:01
|
If I have this..INSERT INTO table1 ( field1 )SELECT fieldA, fieldB FROM table2 This will throw an error because there are more fields in the select result than in the insert statement.Is it possible to still retrieve two fields in the select and determine using code which value to assign to the field1 of table1?Cheers,X-Factor |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-10-25 : 16:25:51
|
| INSERT INTO table1 ( field1 )SELECT case when <condition> then fieldA else fieldB endFROM table2==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2003-10-25 : 16:59:50
|
| Much appreciated nr. |
 |
|
|
|
|
|