ISNULL and nullif in SQL Server

Source: Internet
Author: User

There are two parameters in SQL Server, syntax:
ISNULL (Check_expression, Replacement_value)

Check_expression and Replacement_value data types must be consistent
If Check_expression is NULL, the Replacement_value is returned
If Check_expression is not NULL, the check_expression is returned

Nullif is used to check two expressions, syntax:

Nullif (expression, expression)

If two expression equals, returns NULL, which is the data type of the first expression
Assuming that two expression is not equal, the first expression is returned

sql a description of the functions Nullif and isnull for which two inferences are null:
Nullif: Requires two parameters, assuming that two of the specified expressions are equivalent, returns null
Sample: Nullif (b)
Description: Assuming that A and B are equal, then return null, assuming that the unequal return of a
Select Nullif (' eqeqweqwe ', ' 1 ') results in Eqeqweqwe
Select Nullif The result is null
A and B are of the same type
ISNULL: Requires two parameters, the target is null to replace the specified value, if the first parameter is not NULL, the first parameter
Sample: ISNULL (A, b)
Description: Assume that A and B are null at the same time, return NULL, assume that A is null,b not NULL, return B, assume that A is not NULL for NULL,B and return a, assuming that both A and B are not NULL returns a
Select ISNULL (null,null) The result is a null
Select ISNULL (null,33) Result of a
Select ISNULL (' DDD ', null) result is a DDD
Select ISNULL (44,33) result is a.
IsNumeric: Verify that the expression is a valid numeric form

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.