Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Nulll SQL Server: NULLIF Function in SQL Server

Understand Nulll SQL Server: NULLIF Function in SQL Server with clear explanations, practical examples, and useful tips. This updated guide covers the...

Published: · 3 minutes read
Table of Contents

Nulll SQL Server: NULLIF Function in SQL Server is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

This guide will show you in detail how to use the NULLIF function handler in SQL Server with specific syntax and examples to better visualize and capture functions.

Describe

The NULLIF function in SQL Server compares two expressions to be passed. If the first expression is equal to the second expression, NULLIF will return NULL. Otherwise, the function will return the first expression, expression 1.

Syntax

To use the NULLIF statement in SQL Server, we use the following syntax:

 NULLIF(bieuthuc1, bieuthuc2) 

Parameters :

  1. bieuthuc1, bieuthuc2: expressions to compare. The values in the expression must belong to the same data type.

Note :

  1. NULLIF function can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.

For instance,

See how to use the NULLIF statement in SQL Server.

 SELECT NULLIF('TipsMake.com', 'TipsMake.com'); 
 Result: NULL (tr? v? NULL v? c?c gi? tr? b?ng nhau) 
 
 SELECT NULLIF('TipsMake.com', 'Tipsmake'); 
 Result: 'TipsMake.com' (tr? v? gi? tr? ??u ti?n v? c?c gi? tr? kh?c nhau) 
 
 SELECT NULLIF(12, 12); 
 Result: NULL (tr? v? NULL v? c?c gi? tr? b?ng nhau) 
 
 SELECT NULLIF(12, 45); 
 Result: 12 (tr? v? gi? tr? ??u ti?n v? c?c gi? tr? kh?c nhau) 
 
 SELECT NULLIF('2019-05-01', '2019-05-01'); 
 Result: NULL (tr? v? NULL v? c?c gi? tr? b?ng nhau) 
 
 SELECT NULLIF('2019-05-01', '2019-04-30'); 
 Result: '2019-05-01' (tr? v? gi? tr? ??u ti?n v? c?c gi? tr? kh?c nhau) 

FAQ

What should you know about describe?

The NULLIF function in SQL Server compares two expressions to be passed. If the first expression is equal to the second expression, NULLIF will return NULL. Otherwise, the function will return the first expression, expression 1.

What should you know about syntax?

To use the NULLIF statement in SQL Server, we use the following syntax:

What should you know about for instance,?

See how to use the NULLIF statement in SQL Server.

David Pac - IT Expert and Technology Writer

Written by David Pac

IT Expert & Technology Writer

David Pac has 20+ years of experience in software development, Windows troubleshooting, computer hardware diagnostics, and system administration.

Expertise: Windows | Software | Hardware | System Troubleshooting

Was this article helpful?

Your feedback helps us improve.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.