This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
 

A stock trading company has many reports created using Excel. At the end of each day, the company transmits the data generated by these reports to the SQL Server database.

As part of data validation checks, often arises the need to locate columns with invalid values. In the following exercise you are asked to locate empty columns (columns where all values equal Null).

This exercise is composed of two tasks –

  • Locating all empty columns in specific table (where the number of columns is known)
  • Locating all empty columns in a database.

 

Locating all empty columns in a specific table

Given a table with the following structure:


CREATE TABLE customers
(customer_id int,
customer_name varchar(250),
customer_address varchar(250),
customer_age int)
GO

Would you like to read more?