[Sql]sql function Coalesce returns the first non-null value

Source: Internet
Author: User
Tags getdate

Here are a few more useful examples:

First, take a look at the use of this function from MSDN, the COALESCE function (hereinafter referred to as the function), and return a non-null value for a parameter. Such as:

    1. SELECT COALESCE (null, null, GETDATE ())



Since all two parameters are null, the value of the GETDATE () function is returned, which is the current time. That is, the first non-null value is returned. Since this function returns the first non-null value, there must be at least one non-null value inside the parameter, and if you use the following query, you will get an error:

 
    1. SELECT COALESCE (null, null, null)


[Sql]sql function Coalesce returns the first non-null value

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.