SQL statements (T-SQL summary) draw these figures with T-SQL

Source: Internet
Author: User
Today, I would like to share with you the SQL statements, T-SQL usage and syntax, as well as some examples, the purpose is to help everyone to review the basic statements of T-SQL, so that the project can be used more quickly. Of course, it should be learned and summarized for new users.

Today, I would like to share with you the SQL statements, T-SQL usage and syntax, as well as some examples, the purpose is to help everyone to review the basic statements of T-SQL, so that the project can be used more quickly. Of course, it should be learned and summarized for new users.

I personally feel that database is very important for programmers, both JAVA programmers, dotnetprogrammers, and other programmers. In order to help you better review the T-SQL, I use free time to sort out the T-SQL statements and syntax. Hope to be useful to everyone!

Okay! Let's first look at several images:

The above graphics are implemented with T-SQL, the article at the end of the we together with the T-SQL to draw these graphics.

First, let's look back at the basic syntax of T-SQL:

: Returns the absolute value.;

For example, the value of () is:

:Square Root;

For example, the value of () is:

:Return0 ~ 1Between random floatValue;

: Returns less than or equal to XThe maximum integer of the value.;

For example, the value of () is:

: Returns X or greater than or equal to X.The smallest integer of the value;

For example, the value of () is:

: Rounding function, lengthIf it is positiveNumber of decimal places rounded to lengthIf it is negativeLength from the left decimal pointThe length is roundedIt is a negative number and its absolute value is greater than X.IntegerNumber, the function value is 0;

For example, the value of (,) is (,) and the value of (,) is:

: Evaluate the symbolic function, X> 0Then sign (x) = 1; X = 0Then sign (X) = 0; X <0Then sign (X) =-1

For example, the value of () is () and the value of () is:

: XYPower to power;

For example, the value of (,) is:

: Returns the ASCII value of the leftmost character of a character expression.Code value;

For example, the value of () is:

: Used to convert ASCIIThe code is converted to a character. If no value is entered ~ 255ASCIIThe return value is NULL;

For example, the value of () is.

: Converts all strings to lowercase letters;    

For example, the value of () is qingpingguo.

: Converts all strings to uppercase;

For example, the value of () is QINGPINGGUO.

: Remove left and right spaces;

Example (left blank): () value: qingapple blog

: Returns a specified number of spaces;

: Specify the number of repeated strings;

For example, the value of (,) is green apple

: Returns the number of characters from the left of a known string;

For example, the value of (,) is

: Returns the number of characters from the right of a known string;

Example: (,) value: In the blog

: Returns the length of the number of bytes of the string, and calculates the space at the end of the string. You can use it to check the dynamic lengths of varchar and text;

For example, the value of () is 14.

: Returns a string with a 'length' starting from the 'start position' on the left of the string. The expression can be a string, a binary string, or an expression containing a field name or variable. Note that the SUBSTRING () function cannot be used for the TEXT and IMAGE data types;

For example, the value of (,) is:

: The length of the returned expression. Note that it returns the number of characters rather than the number of bytes. Do not calculate trailing spaces of strings;

For example, the value of () is 10.

: String3Replacement string1All strings in2Character;

For example, the value of (,) is:

: Delete string 1Specify the position to start specifying the length of the string, and insert string 2 at the specified position;

For example, the value of (,) is:

: Reverse the character arrangement order of the specified string;

For example, the value of () is 54321.

: Return string 1In string 2From the given'Start position'Search;

For example, the value of (,) is 9.

The so-called conversion function is to convert the expression of a data type conversion to another data type.

For example, the value of () is:

For example, the (), () value is:

The following is a function used to evaluate the difference.DatediffFunction;

For example, the value of (yy,) is (mm,) and the value is:

An aggregate function is a statistical function. It is mainly used to calculate a group of values. Its functions are sum), Minimum (min)Max), Calculates the total number of rows (count)And avg)

For example, sum: (Name) TableName

Returns user information to the client.

For example, the screen displays "Three green apple words".

Used to notify SQLEnd of a batch of statements

GoDuplicate value drop

Used to declare Variables

Example:

Assign values to variables

Example:

In SQLFor Loop (It seems that in SQLThere are not many keywords used for loop)

Syntax: conditional expression command line or program block

While is more important. Let's give an example to further understand the While loop:

       

Judgment statement

To judge whether statements are used more often, let's give an example;

Q: What is the maximum number of numbers a, B, and c?

  , , ,                 

Used to set a program block... ENDAll programs are considered as one unit.

Determine whether there is

It is also used for judgment, and IFThe statement format is:

Formula 1 result 1 formula n result n

  Used to end the execution of the current program and return to the previous program or other program that calls it. You can specify a return value in parentheses.

It is used to change the process of program execution, so that the program jumps to the specified program line with the identifier and continues to execute. Note that the identifier of the jump target can be a combination of numbers and characters,:"End, for example, "1023: "" Qingpingguo :"

Qingpignguo

Output result: 12345

The last one is interesting:

It is used to pause program execution and continue to run the program until the specified time is reached or the specified time is reached.

Syntax: {delay time}

Explanation:

(1) 'Time' must be DATETIMEType data, which cannot contain dates, such as '10: 12: 05'

(2) DELAY:Used to set the length of the wait time, which can be up to 24Hours. (Is a time interval)

(3) TIME: Used to set the wait time (a specific time)

 delay        

    ( ((), , 

Output result of right triangle:

      (    (  (         

Square output result:

  ,    ( (( (())((), ,)(()   (( (())((), ,)(()   (

Diamond output result:

  ,    (( (())((), ,)(() 

Trapezoid output result:

      (    (  (         

Rectangular output result:

  ,     (( (())((), ,)(()   (())((), ,)(() (( (())((), ,)(() (  (())((), ,)(()

Circular output result:

The End! The above is all the content in this article, which may not be comprehensive enough. If you have any shortcomings, I hope you can add more and give more comments! Thank you!
Author: green apple

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.