select customernumber into total
from (select customernumber
from ccsowner.customer
where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))
通过。
创建的临时表Create Table Total
(
customernumber Int
)
答案 0 :(得分:1)
Select Into仅在表不存在时才有效。您可以使用以下SQL将数据插入现有表。
试试这个 -
Insert into Total
select customernumber
from ccsowner.customer
where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS)
如果要使用SELECT INTO,可以使用以下SQL(它将动态创建Total表,如果Total表已经存在则会出错):
;with cte_Cust As (
Select customernumber
from ccsowner.customer
where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))
Select customernumber Into Total
From cte_Cust