Monday, May 28, 2007

The object name ... contains more than the maximum number of prefixes. The maximum is 2

Problem:-
update ServerName.AAD.dbo.t_employeeset ServerName.AAD.dbo.t_employee.work_shift = wa.work_shiftfrom t_employee wawhere ServerName.AAD.dbo.t_employee.id = wa.idand wa.id = '105'
I was getting the following:Server: Msg 117, Level 15, State 2, Line 4The number name 'ServerName.AAD.dbo.t_employee' contains more than the maximum number of prefixes. The maximum is 3.

Solution:-
It's a simple, but not obvious, answer. Put the table you are updating in the FROM clause with an alias and update the alias, as follows:
update laset la.work_shift = wa.work_shiftfrom ServerName.AAD.dbo.t_employee la, t_employee wawhere la.id = wa.idand wa.id = '105'

No comments: