August 19, 2004 at 5:05 am
Dear All,
Am a newbie at this SQL stuff. Essentially, what I want to do, insert data into a column of a table - Contacts.WebUserID from a table in another database. Thus the databases are different. The table/column from the other database is called Users.ID and in both tables there are columns that can be joined as they contain the same data Contacts.ContactID and Users.ContactIDAlias.
Can seem to get the script to work.
Help.
TheKutts
August 19, 2004 at 6:42 am
UPDATE contacts INNER JOIN contacts ON users.contactidalias = contacts.contactid SET contacts.webuserid=users.id
MVDBA
August 20, 2004 at 12:55 pm
You need to use a three-part name to refer to a table in another database: <database>.<schema>.<table>. If the table is owned by dbo the middle part can be empty.
update c set WebUserID = u.ID
from Contacts c
inner join OtherDB..Users u ON c.ContactID = u.ContactIDAlias
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply