为什么在数据库中执行一条数据库语句报错,但是代码能够执行下去呢
例如SELECTServerStateasSERVERSTATE,HostGroupASHOSTGROUP,UUIDASUUID,ServerModeASSERVERMO...
例如
SELECT ServerState as SERVERSTATE, HostGroup AS HOSTGROUP,UUID AS UUID, ServerMode AS SERVERMODE,MEMORYRATE,
MemoryUsed AS MEMORYUSED,MemoryTotal AS MEMORYTOTAL, CPURate AS CPURATE, LastUpdatetime as LASTUPDATETIME,
MANAGESCRIPT_CONT, QUEUE_CONT,BP_CONT from
(select
sum(case t.FILENAME when'ManageScript'then FileNumber else 0 end) MANAGESCRIPT_CONT,
sum(case t.FILENAME when'Queue'then FileNumber else 0 end ) QUEUE_CONT,
sum(case t.FILENAME when'BP'then FileNumber else 0 end) BP_CONT,SERVERNUM
from T_FileCount t
group by SERVERNUM ) a left outer join T_RecordServerState on a.SERVERNUM = T_RecordServerState.uuid where LASTUPDATETIME > convert(char(10),getdate(),120) ORDER BY HOSTGROUP ,UUID,这条语句 就总是报 对象名 'T_FileCount' 无效。 具体的T_FileCount表我是有的 展开
SELECT ServerState as SERVERSTATE, HostGroup AS HOSTGROUP,UUID AS UUID, ServerMode AS SERVERMODE,MEMORYRATE,
MemoryUsed AS MEMORYUSED,MemoryTotal AS MEMORYTOTAL, CPURate AS CPURATE, LastUpdatetime as LASTUPDATETIME,
MANAGESCRIPT_CONT, QUEUE_CONT,BP_CONT from
(select
sum(case t.FILENAME when'ManageScript'then FileNumber else 0 end) MANAGESCRIPT_CONT,
sum(case t.FILENAME when'Queue'then FileNumber else 0 end ) QUEUE_CONT,
sum(case t.FILENAME when'BP'then FileNumber else 0 end) BP_CONT,SERVERNUM
from T_FileCount t
group by SERVERNUM ) a left outer join T_RecordServerState on a.SERVERNUM = T_RecordServerState.uuid where LASTUPDATETIME > convert(char(10),getdate(),120) ORDER BY HOSTGROUP ,UUID,这条语句 就总是报 对象名 'T_FileCount' 无效。 具体的T_FileCount表我是有的 展开
1个回答
展开全部
我遇到过相反的情况, 我在ACCESS中调试了一条语句,成功通过, 然后放到代码中竟然通不过, 后来反复试验发现,代码中SQL语句语法竟然和ACCESS中稍稍区别,当时好像是通配符有区别
更多追问追答
追问
它这个总有个准确的说法吧,不可能这样子的无缘无故吧,我在oracle跟sqlserver中使用相同意思的语句,都不能通过,而且报错都不一样
追答
那次我查找了很多资料, 对于SQL SERVER 、 access在某些语句上的差异都可以找到专门相关的文章, 代码中到底时个什么规则,还真没找到。
对于你的情况,其实完全可以忽略过去,你只是好奇,对你的工作没影响。
我在代码中通不过,找了整整一天才发现代码中的SQL语句竟然有区别,不过幸好都是小差异,平时基本感觉不到
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询