查询未运行

时间:2012-03-15 09:51:37

标签: sql sql-server sql-server-2008

MUTANT TABLE不存在。我的查询工作很精细,但是当我尝试将结果放入一个不存在的新表时,显示出一些错误。

select 
   'Ordinary' , 
   pincode , 
   year ( Date_val ), 
   MONTH ( Date_val ), 
   (100 - cast ( Arr_8 as int )/ cast ( Arr_5 as int )* 100 )
into mutant
from 
( 
   select * from arrow_29june_2010 union all
   select * from arrow_dtp_upg_2009 
) A
where 
   cast ( arr_5 as int )<> 0

1 个答案:

答案 0 :(得分:3)

您需要在select中命名列,以便将它们插入新表中:

select 'Ordinary' Ordinary, pincode , year ( Date_val ) Year, MONTH ( Date_val ) Month, (100 - cast ( Arr_8 as int )/ cast ( Arr_5 as int )* 100 ) Something
into mutant

from ( select * from arrow_29june_2010 union all

select * from arrow_dtp_upg_2009 ) A

where cast ( arr_5 as int )<> 0
编辑:忘了别名'普通'