Question: ```
update [RegistryCopy].[dbo].[RegFile_New]
SET r.[FileNo] = v.[Cont#Account (New ACC)]
where r.[FileNo] IN
    (
    SELECT r.[FileNo]
    FROM [RegistryCopy].[dbo].[RegFile_New] as R
    INNER JOIN
    [Registry_Malta_Recovered].[dbo].OLD_NEW_AccountsFromSap as v ON 
     r.FileNo] = v.[Acct in legacy (Old ACC)]
      where 
      r.[FileNo] = ('1000040000')
     )

```

I'm getting the error message:

> 
> The multi-part identifier "r.FileNo" could not be bound.
> 
> 
>

Answer: 
Your statement is invalid. You're referring to aliases in the outer query that are defined in the inner query (subquery), and you're also referring to fields in the outer query for tables that are only defined in the inner query.

This is the closest approximation of your query:

```
UPDATE r
SET [FileNo] = v.[Cont#Account (New ACC)]
FROM [RegistryCopy].[dbo].[RegFile_New] AS R
INNER JOIN [Registry_Malta_Recovered].[dbo].OLD_NEW_AccountsFromSap AS v
    ON r.[FileNo] = v.[Acct in legacy (Old ACC)]
WHERE r.[FileNo] = ('1000040000')

```
It is complaining because you are telling it to update this table/alias called `r` but this `r` is not found in the table name above.

You can rewrite the query to be this:

```
UPDATE r
SET r.[FileNo] = v.[Cont#Account (New ACC)]
FROM [RegistryCopy].[dbo].[RegFile_New] as r
INNER JOIN [Registry_Malta_Recovered].[dbo].OLD_NEW_AccountsFromSap as v
    ON r.FileNo] = v.[Acct in legacy (Old ACC)]
WHERE r.[FileNo] = ('1000040000')

```