sql update in a select across a Join

Hello All.

I am trying to do an update on one table when there is a matching record in another table on a diffrent database below is my code. She builds find but does not work ... any IDEAS?


SELECT     a.*, b.*
                           FROM         dbo.tblPayment AS a INNER JOIN
                                                  GradAPP.dbo.Student_INFO AS b ON a.IP = b.IP
                           WHERE     (a.PaymentType = 2)
                                                      UPDATE    b
                                                       SET              b.PaymentStatus = 1
                                                       WHERE     (a.Successfull = 1) AND (b.PaymentStatus = 0)

Open in new window

HawaiiDragonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LowfatspreadCommented:
like this ?
UPDATE GradAPP.dbo.Student_INFO
   SET PaymentStatus = 1
 WHERE exists (select ip from dbo.tblpayment as a 
                where a.Successfull = 1 
                 and a.ip=GradAPP.dbo.Student_INFO.ip
                 and a.paymenttype=2)
   AND PaymentStatus = 0

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HawaiiDragonAuthor Commented:
This is what I have tried to no avail

error
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Wdb_CCPayment.dbo.tblPayment.Successful" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Wdb_CCPayment.dbo.tblPayment.IP" could not be bound.
UPDATE GradApp.dbo.STUDENT_INFO
sET Gradapp.dbo.student_Info.PaymentStatus = 1

WHERE (Wdb_CCPayment.dbo.tblPayment.Successful = 1) and (Gradapp.dbo.student_Info.pAYMENTsTATUS = 0) and (Gradapp.dbo.student_Info.IP = Wdb_CCPayment.dbo.tblPayment.IP)

Open in new window

0
HawaiiDragonAuthor Commented:
UPDATE GradAPP.dbo.Student_INFO
   SET PaymentStatus = 1
 WHERE exists (select ip from WDB_CCPayment.dbo.tblpayment as a
                where a.Successful = 1
                 and a.ip=GradAPP.dbo.Student_INFO.ip
                 and a.paymenttype=2)
   AND PaymentStatus = 0

Low fat you rock!!!
0
HawaiiDragonAuthor Commented:
UPDATE GradAPP.dbo.Student_INFO
   SET PaymentStatus = 1
 WHERE exists (select ip from WDB_CCPayment.dbo.tblpayment as a
                where a.Successful = 1
                 and a.ip=GradAPP.dbo.Student_INFO.ip
                 and a.paymenttype=2)
   AND PaymentStatus = 0

Low fat you rock!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.