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.
Main uses:
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
The as
keyword is used when you create or alter views, procedures, functions and triggers.
Example:
create procedure Test
as
select 1
The keyword is also used with a different meaning to create aliases for tables and fields in a query.
Example:
select u.usnm as UserName, u.pwd as UserPassword
from applicationusertable as u
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With