Use of functions like Decode, substr, InStr, replace, length, etc. in SQL Server statements 2016.7.10

Source: Internet
Author: User

Decode () corresponds to case-when function

Case CHARINDEX ('/', start_point_name)

When 0 then Start_point_name

else substring (start_point_name,1,charindex ('/', start_point_name)-1)

End

Note: The syntax is different when SQL Server uses case to determine whether it is null

Null should be judged by:

Case when identifier was NULL then Airway_point_name else identifier end,

The simplest way is to use the ISNLL function IsNull (idenfier, Airway_point_name)

No way! IsNull (Idenfier, Airway_point_name) will idenfier shortened, originally 5 characters, replaced only 4 characters, the reason is unknown, it is best not to IsNull

The InStr corresponds to the charindex ('/', start_point_name) function, except that the meaning of the two parameters is reversed and is counted starting from 1.

SUBSTR corresponds to the substring parameter exactly the same, but the length parameter cannot be missing, cannot default to the end, can give only a large enough length value.

The Replace function is exactly the same

The length function corresponds to the Len function

Use of functions like Decode, substr, InStr, replace, length, etc. in SQL Server statements 2016.7.10

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.