Learner
Learner

Reputation: 1695

Error near Where in SQL command

I have the following code to update two columns from two tables. I get an error near 'Where'. But, I don't see any error in doing the same. Any help ? Thanks :)

UPDATE MP 
SET MI.Accountid = AD.Accountid
FROM [GSF].[dbo].[MetaInformation] MI
inner join [GSF].[dbo].[AllocationDetails] AD
WHERE MI.AccountDetailID = AD.AccountDetailID

Upvotes: 0

Views: 53

Answers (1)

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239646

You need ON to specify the JOIN condition:

UPDATE MI 
SET Accountid = AD.Accountid
FROM
    [GSF].[dbo].[MetaInformation] MI
        inner join
    [GSF].[dbo].[AllocationDetails] AD
        ON
            MI.AccountDetailID = AD.AccountDetailID

You also can't specify a rowset alias on the left hand side of assignment in the SET clause.

Upvotes: 3

Related Questions