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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Selecting information from another database

Author  Topic 

Mredfer
Starting Member

4 Posts

Posted - 2009-12-14 : 13:08:15
Hi,

I am very new to SQL and am trying to update some information in one database from information in a second database (see below) but cannot get it to "set" the information in database1(SOTEST) from the information in database2 (SOTRANSFER).


USE SOTEST
update Project

set PROJ_ANAL_ID_2
=Use SOTRANSFER select analysis_code_2 from contract where contract_code='111507'
where proj_code='111507'


Thanks very much in advance

Mike






I Always Need HEEEELP!!

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-14 : 13:14:50
=Use SOTRANSFER select analysis_code_2 from contract where contract_code='111507'

select analysis_code_2 from SOTRANSFER.dbo.contract where contract_code='111507'

or better yet
USE SOTEST

update p
set PROJ_ANAL_ID_2 = c.analysis_code_2
FROM Project p
JOIN SOTRANSFER..contract c
On c.contract_code = p.proj_code
WHERE p.proj_code = 111507
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-14 : 13:19:49
If both the DB's are on the same server.
Go to Top of Page

Mredfer
Starting Member

4 Posts

Posted - 2009-12-15 : 04:23:17
Thanks very much,

Will try that now.

I Always Need HEEEELP!!
Go to Top of Page

Mredfer
Starting Member

4 Posts

Posted - 2009-12-15 : 05:54:04
Thanks very much,

It is now working, thanks very much.

I Always Need HEEEELP!!
Go to Top of Page
   

- Advertisement -