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 2000 Forums
 SQL Server Development (2000)
 Using Two Databases in the Same Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-20 : 09:42:08
Mindi writes "I want to select all the records in DatabaseA and all records in DatabaseB where Column1 and Column2 in both databases contain the same information and then update Column3 in DatabaseA with "Y".

Here's the code that works - to a point. I can SELECT all the records, but I've been unable to UPDATE the records I've selected.

SELECT DatabaseA.OwnerName.TableName.Column1, DatabaseB.OwnerName.Tablename.Column2

FROM DatabaseA.OwnerName.TableName, DatabaseB.OwnerName.TableName

WHERE DatabaseB.OwnerName.TableName.Column2 = DatabaseA.OwnerName.TableName.Column1

When I add an UPDATE statement it blows up. I've tried using UNION and writing the update query under that, but it still blows up.

Help!

Thanks,
Mindi"

Nazim
A custom title

1408 Posts

Posted - 2002-03-20 : 10:00:54


update i set i.colum3='Y' from database.ownername.tablename i
inner join database.ownername.tablename l
on i.coumnname=l.columname


HTH

--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -