How to know where AS keyword should be used?
sql, sql-server, t-sql
Solution
Main uses:
- Aliases for tables and columns
- Between CREATE and definition
- CAST AS newtype
Examples
SELECT
foo AS tom,
foo + bar AS dick,
CAST(bar AS varchar(50)) AS harry
FROM
fizz AS f
CREATE VIEW/PROC/FUNCTION etc
AS
... proc or view of udf etc definition
GO
Problem
There is a `AS` keyword in `TSQL` but in what situations I should use it ? For example : `Create View StatisticalData AS Select * from People` We used `AS` keyword in this statement but when creating tables we don't use it , I mean I am kinda confused. Could you please tell me, in what kinda position I should use AS. I mean it is used to assign value to a variable? Thanks in advance.