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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-04-08 : 09:49:58
|
| Kwesi writes "How do I populate a new field (or column) in an existing table using a select statement from another table. the select statement returns over 3,000 records from the original table.In my where clause I'm using a common field (PdtID)in both tables to insert the new records.Both tables are in different databases.DATABASE VERSION: SQL 2000My Code:Update Database1.owner.TableToBeUpdated.FieldName Set Database1.owner.TableToBeUpdated.FieldName = SELECT Database2.owner.TableWithOriginalData.DataFieldName FROM Database2.owner.TableWithOriginalData INNER JOIN Database2.owner.AnotherTable ON Database2.owner.TableWithOriginalData.DataFieldName = Database2.owner.AnotherTable.FieldnameWhere Database2.owner.TableWithOriginalData.PdtID = Database1.owner.TableToBeUpdated.PdtID" |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-04-08 : 10:08:18
|
| update dt1 Set dt1.FieldName = dt2.DataFieldName FROM Database2.owner.TableWithOriginalData dt1 INNER JOIN Database2.owner.AnotherTable dt2 ON dt1.DataFieldName = dt2.Fieldname and dt1.TableWithOriginalData.PdtID = dt2.TableToBeUpdated.PdtIDHTH-------------------------------------------------------------- |
 |
|
|
|
|
|