这是在一个存储过程里:
我想把这条插入语句用EXEC命令把其中的变量写活,CNWinImportantProject在(A数据库)和SystemInitialize在(B数据库)两张表是处于两个数据库中的表,[email protected],@NextDateTime,[email protected]
@PrevDateTime datetime,
@NextDateTime datetime,
@Type varchar(20)
请把下面这句Insert into ... select 语句用EXEC语句写出来
INSERT INTO CNWinImportantProject(
ProjectID,
ProjectStartDate,
ProjectEndDate,
ConferTotalCost,
CNWinTotalCost,
Type,
BelongMonth
)
select projectid,@PrevDateTime,@NextDateTime,0,0,@Type,0
from SystemInitialize
------解决方案--------------------
declare @PrevDateTime datetime,
@NextDateTime datetime,
@Type varchar(20),
@sql varchar(8000)
select @sql= '
INSERT INTO CNWinImportantProject(
ProjectID,
ProjectStartDate,
ProjectEndDate,
ConferTotalCost,
CNWinTotalCost,
Type,
BelongMonth
)
select projectid, ' ' '+convert(char(19),@PrevDateTime,120)+ ' ' ', ' ' '+convert(char(19),@NextDateTime,120)+ ' ' ',0,0, ' ' '[email protected]+ ' ' ',0
from SystemInitialize '