
今天我真的要疯了,这一个存储过程弄了快一天了,还是各种问题。
大家帮忙给看看,如果把查询的列换成 * 就没问题了,
代码贴出来
declare @aaaa nvarchar(100)
set @aaaa = 'select stcd , sum(DRP) as daydrp,MAX(TM) as lasttm from ST_PPTN_R where TM Between '''
+ CONVERT(nvarchar(100), DATEADD(HH, 8, DATEADD(DD, DATEDIFF(DD, 0, GETDATE()), 0) ),120)
+ ''' and ''' + CONVERT(nvarchar(100), GETDATE() ,120 )+ ''' group by stcd'
exec(@aaaa)
------解决思路----------------------
declare @aaaa nvarchar(4000)
set @aaaa = 'select stcd , sum(DRP) as daydrp,MAX(TM) as lasttm from ST_PPTN_R where TM Between '''
+ CONVERT(nvarchar(100), DATEADD(HH, 8, DATEADD(DD, DATEDIFF(DD, 0, GETDATE()), 0) ),120)
+ ''' and ''' + CONVERT(nvarchar(100), GETDATE() ,120 )+ ''' group by stcd'
exec(@aaaa)
你换大点的试下