declare @clr_rate float,@qt_wo_ytd  decimal, @qt_wo_td decimAL
----統計各站不良
if (exists(select * from sysobjects where id=object_id(N'mwo3move_Vel')))
drop table mwo3move_Veldeclare @Startdate varchar(8)
declare @Enddate varchar(8)
SELECT @Startdate='20051201'
SELECT @Enddate='20051225'
 select a.dt_wk,a.wc_name,b.no_item_p,item_name,sum(QT_wip_o) as QT_wip_o,cast(@clr_rate as float) as clr_rate,cast(@qt_wo_ytd as decimal) as qt_wo_ytd, cast(@qt_wo_td as decimal) as qt_wo_td into mwo3move_Vel from mwo3move_d b
left join mwo3move a on a.id_tran=b.id_tran where  b.no_item_p>'' and a.dt_cret>=@startdate and a.dt_cret<=@enddate and a.optype_code='101' and A.DT_WK<>'SR010' --and b.no_wc_out_name  not  like '委外%' 
 group by a.dt_wk,a.wc_name,b.no_item_p,item_name
select * from mwo3move_Vel
---我這樣賦值就可以查詢數據。問題出在哪裡請高手幫忙 先謝謝!!