ISNULL and nullif in SQL Server

Source: Internet
Author: User

ISNULL (Check_expression, Replacement_value)

The check_expression and Replacement_value data types must be the same, and if Check_expression is NULL, Replacement_value is returned if Check_expression is not NULL, the check_expression is returned

Nullif (expression, expression)

If two expressions are equal, returns NULL, which is the data type of the first expression, and if two expression is not equal, returns the first expression

Nullif: Requires two parameters and returns null if two of the specified expressions are equivalent
Example: Nullif (A, B)
Description: If A and b are equal, then return NULL if not equal to return a
Select Nullif (' eqeqweqwe ', ' 1 ') turns out to be eqeqweqwe
Select Nullif () result is null

The type of a and B should be consistent

ISNULL: Two parameters are required, the goal is to replace NULL with the specified value, and if the first argument is not NULL, the first argument is returned
Example: ISNULL (A, B)
Description: If A and b are both NULL, return NULL if A is null,b not NULL, return B if a is not null,b null returns a If both A and B are not NULL returns a
Select ISNULL (null,null) result is null
Select ISNULL (null,33) results are 33
Select ISNULL (' DDD ', null) result is DDD

Select ISNULL (44,33) results are 44

IsNumeric: Verify that the expression is a valid numeric form

ISNULL and nullif in SQL Server

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.