Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 在sql中,无重复地从一个表插入到另一个表_Sql Server 2008 - Fatal编程技术网

Sql server 2008 在sql中,无重复地从一个表插入到另一个表

Sql server 2008 在sql中,无重复地从一个表插入到另一个表,sql-server-2008,Sql Server 2008,这对我来说曾经奏效,但现在脚本不起作用了 我想进入另一张桌子,但没有任何重复 select * from [Data_Guru].[dbo].[MORTGAGE_AUG_27_new_1] where Phone not in (select Phone from [dbo].MASTER_LIST) 这是我遇到麻烦的底部部分,当我将其更改为另一个表时,它会显示不在该表中的所有数字。我确实知道这两个表中不应该有很多重复的记录。。它们是完全不同的类别…请帮助通常“in”和“not in”查

这对我来说曾经奏效,但现在脚本不起作用了 我想进入另一张桌子,但没有任何重复

 select * from [Data_Guru].[dbo].[MORTGAGE_AUG_27_new_1] 
 where Phone not in (select Phone from [dbo].MASTER_LIST)
这是我遇到麻烦的底部部分,当我将其更改为另一个表时,它会显示不在该表中的所有数字。我确实知道这两个表中不应该有很多重复的记录。。它们是完全不同的类别…请帮助通常“in”和“not in”查询的问题是存在NULL。试试这个:

select *
from [Data_Guru].[dbo].[MORTGAGE_AUG_27_new_1]
where Phone not in (select Phone from [dbo].MASTER_LIST where Phone is not null) 

呃,“选择不同的”可能;)?我试过了。这是令人沮丧的,因为我上周第一次这么做时它就起作用了,现在它只使用一张桌子,而不是主桌子。。。还有其他建议吗?
select distinct * from [Data_Guru].[dbo].[MORTGAGE_AUG_27_new_1] t1
where NOT EXISTS (select Phone from [dbo].MASTER_LIST where t1.phone=t2.phone)