SQL Server function Chapter mathematical Functions, String functions, conversion functions, time-date functions

Source: Internet
Author: User
Tags add time getdate mathematical functions reserved square root time and date

Functions in a database are similar to functions in C #

sequentially,

The price is special here.

Print can be printed in the Message bar.

Mathematical functions

Ceiling () The upper limit does not care how big the decimal point is, directly ignore

Floor () lower limit ibid.

Round (column name, number of reserved digits) rounding reserved decimals the last digit in the number of reserved digits is not enough for the next one to look at.

ABS () Absolute---anti-lock 233

Pi () is the query for a PI

SQRT () square root

String functions

Upper () All Caps

Lower () all lowercase

Ltrim/rtrim () remove left or right space trim cannot be used alone to show him the direction.

Replace (' string ', ' value to replace ', ' what value to replace ') replaces if there are multiple values in the string that need to be replaced

SUBSTRING (' string ', ' index value ', ' intercept quantity ') intercept the index value here from 1, or you can precede it with left or right to start

Len () length Gets the length of the string this is different from the length in C #.

Conversion Functions

Here is an example first;

Select Code+name from Car; The query here will display the code and name two varchar type Lian as a string concatenation.

Similarly, if it is a column of two value types, it will follow the mathematical operation

Convert (type, column name) type conversion

Cast (column name as type)

Time-Date function

GETDATE () Gets the current time

Year (GETDATE ()) Gets the years in the current time

Month (GETDATE ()) Gets the months in the current time

DAT (GETDATE ()) Day

IsDate (time date) determines whether the time date is correctly returned by the bit type

DATEADD (plus what time, plus how much, time and date) add time

Datename () query time, in parentheses fill in the time format to be queried

Datename (Weekday, time) get the day of the week

Week, time of week

Day, days of the week

DayOfYear, the day of the year

SQL Server function Chapter mathematical Functions, String functions, conversion functions, time-date functions

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.