Description of nullif and isnull in SQL Server

Source: Internet
Author: User

The two functions nullif and isnull in SQL Server are described as follows:

Nullif: two parameters are required.

Example: nullif (A, B)
Note: If a and B are equal, null is returned. If not, A is returned.
Select nullif ('eqeqweqw', '1'). The result is eqeqweqwe.
Select nullif () returns NULL
The types of A and B must be consistent.

Isnull: two parameters are required.

Example: isnull (A, B)
NOTE: If both A and B are null, null is returned. If a is null and B is not null, B is returned. If a is not null and B is null, A is returned, if neither a nor B is null, A is returned.
Select isnull (null, null) returns NULL
The result of select isnull (null, 33) is 33.
Select isnull ('ddd ', null) results in DDD
Select isnull () result is 44

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.