假設我有2個表命名aTable1,aTable2爲什麼Ansi_nulls不起作用?
aTable1有用戶ID設置爲身份和包含以下數據:
userID email FirstName LastName
1 NULL C CC
2 NULL D DD
3 [email protected] A AA
4 [email protected] B BB
5 [email protected] E EE
6 [email protected] NULL NULL
7 [email protected] NULL NULL
aTable2包含以下數據:
userID email FirstName LastName Title
3 [email protected] A AA student
4 [email protected] B BB student
5 [email protected] E EE student
NULL NULL C CC dean
NULL NULL D DD advisor
NULL [email protected] NULL NULL student2
NULL [email protected] NULL NULL student3
我想基於aTable1更新aTable2.userID,但知道兩個表中有空值,所以我這樣做:
set ANSI_NULLS off
update aTable2
set aTable2.userID = a.userID
from aTable a, aTable2 b
where a.FirstName = b.FirstName and a.LastName = b.LastName and a.email = b.email
但是,此更新不會更新所有用戶ID,事實上,它只會更新那些電子郵件不等於空的郵件,但我已將ANSI_NULLS設置爲關閉。 我做錯了什麼?
謝謝,isNull是訣竅。 – ngunha02 2013-02-13 01:43:37
@JackyNguyen - np,很高興能幫到你! – sgeddes 2013-02-13 01:44:18