Parsing your query in SQL Management Studio gives me the following error:
Msg 10739, Level 15, State 1, Line 7 The insert column list used in
the MERGE statement cannot contain multi-part identifiers. Use single
part identifiers instead.
I then remove the identifiers...
MERGE
PopulationData AS a
USING ImagesData AS b
ON a.ID = b.ID
WHEN MATCHED THEN
UPDATE SET a.SURNAME = 'joe123'
WHEN NOT MATCHED THEN INSERT(ID,SURNAME)
VALUES (12454,'joe123');
...and the query parses successfully. Therefore, the syntax error is almost certainly not coming from your MERGE statement. Are you really executing only the statement you posted, or is it part of a larger script or procedure? And if you double-click the error message, it should highlight the line where the syntax error is (at least with SQL 2008).
Update: I noticed that you have tagged the question for SQL 2005 and 2008, but MERGE is only supported in SQL 2008. Parsing the query under SQL 2005 gives the syntax error.
MERGE
keyword?? MERGE is one of those statements that insists on being the first statement in a T-SQL batch.... maybe you have other statements before this??? – marc_s Nov 17 '11 at 16:19