Is there a quick way to check if ANY column is NULL?

后端 未结 4 1455
清歌不尽
清歌不尽 2020-12-06 17:15

I have a table with around 20 columns. Aside from typing out:

Where column1 is null OR column2 is null OR column3 is null etc...

Is there

4条回答
  •  [愿得一人]
    2020-12-06 17:53

    Teaching-to-fish-instead-of-giving-you-the-fish kind of answer here:

    One way of doing it is by creating a Stored Procedure that assembles and runs a dynamic query.

    The Stored procedure will:

    • have a Table name as input parameter.
    • query the meta data system tables for the specific table structure.
    • dynamically assemble a string (the actual query) with the OR statements for that table's columns.
    • run the assembled query and return the result.

提交回复
热议问题