我在数据库中有几个表.我想找到哪些列(在哪些表中)没有任何值(列中的所有NULL).我在下面的例子中,结果应该是
TestTable1 --> Var2
TestTable2 --> Variable1
Run Code Online (Sandbox Code Playgroud)
我不知道如何创建这种查询.非常感谢您的帮助!
--create first table
create table dbo.TestTable1 (
sur_id int identity(1,1) not null primary key,
var1 int null,
var2 int null
)
go
--insert some values
insert into dbo.TestTable1 (var1)
select 1 union all select 2 union all select 3
--create second table
create table dbo.TestTable2 (
sur_id int identity(1,1) not null primary key,
variable1 int null,
variable2 int null
)
--and insert some values
insert into dbo.TestTable2 (variable2)
select 1 union all …Run Code Online (Sandbox Code Playgroud)