Sql-server – SQL Server : View names

sql serversql-server-2008view

I'm coming from an Oracle background and came across code to create a SQL Server view which I've never seen before.

We have a view called viewA (for example)

Within the script to generate the view I see this code

select columnA, columnB, columnC
from tableA as vw_tableB

The question I have is, what is the view really called?

Is it viewA or vw_tableB.

The other question I have is what is the rationale behind this?

Best Answer

The view is called whatever is listed in the CREATE statement, which would look like this in the script.

CREATE VIEW viewA AS

The vw_tableB is an table alias https://technet.microsoft.com/en-us/library/ms187455.aspx

The readability of a SELECT statement can be improved by giving a table an alias, also known as a correlation name or range variable. A table alias can be assigned either with or without the AS keyword: