Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use isnull in sql

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use isnull in sql, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

ISNULL

Replaces NULL with the specified replacement value.

Grammar

: ISNULL (check_expression, replacement_value)

Parameters.

Check_expression is checked to see if it is an expression of NULL. If it is not NULL, this directly returns the value, which is the expression check_expression. If this is empty, directly return the content of the expression replacement_value. Check_expression can be of any type.

The expression that replacement_value will return if check_expression is NULL. Replacement_value must be of the same type as check_expresssion.

Return type

Returns the same type as check_expression.

Annotation

Returns the value of the expression if check_expression is not NULL; otherwise, it returns replacement_value.

Example

1 sample data

The table tb_Student and its sample data are shown in the following figure.

two。 Query requirements

Query the student information whose score is less than or equal to 60 and save it in the table variable @ tempTable. When the student's score is empty, the score is recorded as 0.

Declare @ tempTable table (stuname nchar (10), stuage int, stuscore float); insert into @ tempTableselect name,age,ISNULL (score,0) from tb_Studentwhere ISNULL (score,0)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report