谁能帮小弟看看能不能这么写啊?
alter proc @signal varchar (40),
@unitid varchar(10) ,
@date varchar(10),
@parkname varchar(10)
as
declare @sql varchar (4000)
set @sql='select a.*,b.avg_park
from
(select TTimeStampLocal,'+@signal+'from aa.vw10MinVMP where UnitId = '+@unitid+' and TTimeStampLocal>'''+@date+''') a
inner join
(select AVG( '+@signal+') as avg_park,TTimeStampLocal from aa.vw10MinVMP where ParkName= '''+@parkname+''' and TTimeStampLocal > '''+@date+''') b
on a.TTimeStampLocal=b.TTimeStampLocal'
exec (@sql)
以上修改成功。
执行以下命令
exec
@signal = 'Gen_Phase1_Temp_Avg',
@unitid='30005',
@date='2012-11-10',
@parkname='site'
——————————————————————————
报错:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '.'.
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'b'.