插入时忽略其中包含空值的记录

Joh*_*y B 0 sql sql-server insert sql-server-2008

我有下表:

发明人(发明人ID专利号,发明人第一,发明人最后,城市,州)

其中 inventoryid 为 pk,patentno 为 fk。

这是当前的插入代码:

insert into Inventor (PatentNo, InventorFirst, InventorLast, City, statename, country, NationalityCountry, ResidenceCountry)
select PatentNo, InventorFirstname, InventorLastname, City, statename, country, NationalityCountry, ResidenceCountry
from InventorUpdate;
Run Code Online (Sandbox Code Playgroud)

我想修改它,以便如果 InventorFirstname 和 InventorLastname 字段为空,则它不会插入到inventor表中

Dan*_*iel 5

您如何保留那些字段为空的记录而不被选择?

insert into Inventor (PatentNo, InventorFirst, InventorLast, City, statename, country, NationalityCountry, ResidenceCountry)
select PatentNo, InventorFirstname, InventorLastname, City, statename, country, NationalityCountry, ResidenceCountry
from InventorUpdate
Where InventorFirstname is not null 
And   InventorLastname is not null;
Run Code Online (Sandbox Code Playgroud)