Usage of "SQL Server series" as

Source: Internet
Author: User
Tags aliases microsoft sql server

1 overview

This article provides a brief analysis of the basic usage of as in SQL Server.

2 Specific analysis

2.1 Defining variable Types

1 DECLARE @UserName  as VARCHAR (+) = ' alan_beijing '

2.2 Take aliases

2.2.1 Alias for result set column

Code

1 SELECT orderid,custid,orderdate 2  from

Result

Code

1 SELECT  as ' Order ID '  as ' Customer ID '  as ' Order Date ' 2  from

Result

2.2.2 Aliases for tables

1 SELECT o.orderid,o.custid,o.orderdate 2  from  as O

2.2.3 Aliases for subqueries

1  SELECT childquery_orders.orderdate 2   from 3  (SELECT*4   from Orders 5  WHERE CustID>=5 as Childquery_orders

2.3 Conversion Type

2.3.1 Cast type conversion

1  SELECT CAST ('+'asINT)  --  the

2.3.2 Convert type Conversion

1 SELECT CONVERT (decimal'123.6'--

2.4 Creating a view that represents the base table source

1 CREATE VIEW  2as3SELECT* from Orders

2.5 Other (subsequent additions)

3 references

"01" Microsoft SQL Server 2008 Insider: T-SQL language Basics

"02" Microsoft SQL Server 2008 Tech Insider: T-SQL query

4 Copyrights

    • Thank you for your reading, if there are shortcomings, welcome advice, common learning and common progress.
    • Bo main website: http://www.cnblogs.com/wangjiming/.
    • A very small number of articles using reading, reference, reference, copying, copying and pasting into a variety of ways, most of the original.
    • If you like, please recommend, if you have new ideas, welcome, email: [Email protected].
    • The blog can be reproduced, but must be well-known from the blog source.

Usage of "SQL Server series" as

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.