I am very late to this, but if you don't want to manually list out all the column names and still want to get a table, you can do this in SQL Server (Just replace testTable with your actual table):
--Creates the table the poster wanted
CREATE TABLE testTable (A int, B int, C int)
INSERT INTO testTable (A, C) VALUES (1,1)
INSERT INTO testTable (A, B) VALUES (1,1)
INSERT INTO testTable (B, C) VALUES (1,1)
INSERT INTO testTable (C) VALUES (1)
--Creates the output table which will consist of each column name and the amount of nulls
CREATE TABLE ColumnNames (
ID int IDENTITY(1,1) PRIMARY KEY,
[name] varchar(max),
nullAmount int
)
INSERT INTO ColumnNames ([name])
SELECT [name] FROM sys.columns WHERE object_id = OBJECT_ID('dbo.testTable')
DECLARE @columnIndex INT = 1
WHILE @columnIndex <= ( SELECT COUNT(*) FROM dbo.ColumnNames )
BEGIN
DECLARE @colName nvarchar(max) = (SELECT [name] FROM ColumnNames WHERE ID = @columnIndex)
EXEC('SELECT ' + @colName + ' INTO colTable FROM testTable')
DECLARE @SQL nvarchar(max) = N'UPDATE ColumnNames SET nullAmount = (SELECT COUNT(1) - COUNT(' + quotename(@colName) + ') FROM colTable) WHERE ID = @columnIndex'
EXEC SP_EXECUTESQL @SQL, N'@columnIndex int', @columnIndex
DROP TABLE colTable
SET @columnIndex = @columnIndex + 1
END
--Select the output table and get null info
SELECT * FROM ColumnNames