Tips for SQL Server

Source: Internet
Author: User

Operator priority
When a complex expression has multiple operators, the operator priority determines the order of Operation execution. The execution sequence may seriously affect the obtained values.

Operators have the following priority levels. Evaluate a higher-level operator before a lower-level operator.

+ (Positive),-(negative ),~ (By bit not)


* (Multiplication),/(Division), % (Modulo)


+ (Plus), (+ series),-(minus)


=,>, <, >=, <=, <> ,! =,!>, ! <Comparison operator


^ (Bitwise OR), & (bitwise AND), | (bitwise OR)


Not


And


All, any, between, in, like, Or, some


= (Assign value)

Not commonly used binary operators. They are also of unique use in some aspects, such as positive ^ positive = positive ......

-- Create a table with the same structure as one or more tables

Select * into [new table] from [source table] where 1 = 0

/** // * The table created in this mode only has the basic structure and no additional information such as the primary key */

/** // * Some special sorting methods */
-- 1.
Select * from table
Order
Case ID
When 4 then 1
When 5 then 0
End

-- 2.
Select * from table
Order by ID % 5

-- 3.

Select * from table
Order by right (ID, 3)

-------------------------------
/** // * In short, there are some flexible ideas */

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.