Can I ignore an SQL table alias?

Is it even possible to refer to a strongly typed SQL table object, even after it was an alias?

For example, the following script displays an exception The multi-part identifier "dbo.MyTable.Col3" could not be bound:

SELECT
    *
FROM dbo.MyTable MT
    INNER JOIN dbo.AnotherTable AT ON
        MT.Col1 = AT.Col2
WHERE
    dbo.MyTable.Col3 = 'Foo'
+4
source share
1 answer

No, you can’t.

For a quote from FROM(Transact-SQL) :

The table name cannot be used if an alias is defined.

+6
source

Source: https://habr.com/ru/post/1650883/


All Articles