如何知道应该在哪里使用 AS 关键字? [英] How to know where AS keyword should be used?
本文介绍了如何知道应该在哪里使用 AS 关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
TSQL
中有一个 AS
关键字,但我应该在什么情况下使用它?
There is a AS
keyword in TSQL
but in what situations I should use it ?
例如:Create View StatisticalData AS Select * from People
我们在这个语句中使用了 AS
关键字,但是在创建表时我们不使用它,我的意思是我有点困惑.
We used AS
keyword in this statement but when creating tables we don't use it , I mean I am kinda confused.
你能告诉我,我应该在什么样的位置使用 AS.我的意思是它用于为变量赋值?
Could you please tell me, in what kinda position I should use AS. I mean it is used to assign value to a variable?
提前致谢.
推荐答案
主要用途:
- 表和列的别名
- 在 CREATE 和定义之间
- CAST AS newtype
示例
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
这篇关于如何知道应该在哪里使用 AS 关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文