日期:2014-05-17  浏览次数:20774 次

该怎样写参数
SQL code
declare @ytd int 
set @ytd= 'select' + isnull([Mtd201201],0.0) + 
isnull (Mtd201202,0.0) + 
isnull(Mtd201203,0.0) + 
isnull(Mtd201204,0.0) + 
isnull(Mtd201205,0.0) + 
isnull(Mtd201206,0.0) + 
isnull(Mtd201207,0.0) + 
isnull(Mtd201208,0.0) + 
isnull(Mtd201209,0.0) + 
isnull(Mtd201210,0.0) + 
isnull(Mtd201211,0.0) + 
isnull(Mtd201212,0.0) +' from dbo.RPT_resultA41  where companyid=1 and classify=1'
print @ytd


------解决方案--------------------
终于明白了:
declare @ytd int 
select @ytd=isnull([Mtd201201],0.0) + 
isnull (Mtd201202,0.0) + 
isnull(Mtd201203,0.0) + 
isnull(Mtd201204,0.0) + 
isnull(Mtd201205,0.0) + 
isnull(Mtd201206,0.0) + 
isnull(Mtd201207,0.0) + 
isnull(Mtd201208,0.0) + 
isnull(Mtd201209,0.0) + 
isnull(Mtd201210,0.0) + 
isnull(Mtd201211,0.0) + 
isnull(Mtd201212,0.0) from dbo.RPT_resultA41 where companyid=1 and classify=1
print @ytd