存储过程这样写有问题吗?
@FactoryName varchar(50)
AS
create table table1 (FactoryId int null,totalmonth1 money null)
insert into table1 (FactoryId,totalmonth1)
select tb_User.FactoryId as FactoryId,('$'+ convert( varchar(50),sum(tb_MPCost.MPCost)))as totalmonth1
from tb_MPCost,tb_User,tb_Factory ,tb_CostCenter where
tb_MPCost.PCNumber=tb_User.PCNumber and
tb_CostCenter.CostCenterId=tb_User.CostCenterId
and tb_Factory.FactoryId =tb_User.FactoryId
and tb_Factory.FactoryName= @FactoryName
and tb_MPCost.MPCostTime between convert(varchar(10),DATEADD(day,-DATEPART(DAY,GETDATE())+1,dateadd(month,-1,GETDATE())),23) +' 00:00:00'
and convert(varchar(10),DATEADD(day,-1,DATEADD(month,0,GETDATE()-day(GETDATE())+1)),23)+' 23:59:59'
group by tb_User.FactoryId
drop table table1
为什么老是报这样的错误,请高手帮忙看一下
Msg 260, Level 16, State 1, Procedure FactoryCostTotal, Line 6
Disallowed implicit conversion from data type varchar to data type money, table 'SLFMMS.dbo.table1', column 'totalmonth1'. Use the CONVERT function to run this query.