EXEC('SELECT ProjectType,StatisticsDate,'
+' (SELECT COUNT(*) FROM PCM_PL_SystemApplicationTarget_Detail where '
+' SystemApplicationTargetType="SATT6" AND SID = T.SID) as TargetNum '
+' FROM PCM_PL_SystemApplicationTarget AS T '
+ ' where 1=1')
老是报列名 'SATT6' 无效。
EXEC('SELECT ProjectType,StatisticsDate,'
+' (SELECT COUNT(*) FROM PCM_PL_SystemApplicationTarget_Detail where '
+' SystemApplicationTargetType=''SATT6'' AND SID = T.SID) as TargetNum '
+' FROM PCM_PL_SystemApplicationTarget AS T '
+ ' where 1=1')
是两个单引号
楼上说的没错
sql语句要记得加上单引号撒