无法绑定由多个部分组成的标识列

xu_yunpeng 2008-11-12 10:32:51
大家好,請教個問題,我用的vs2005和sql2005,在查詢分析器中,我有這樣的語句:SELECT G_Location.BranchCode, G_Location.LocationCode, G_Location.LocationName, G_Location.LocationNickName, G_Location.LocalSectionCode, G_Location.CompanyCode, G_Location.GyoumuInfo, MR_HosenLocation.MenuPtnId, MR_HosenLocation.ShinkansenKbn, MR_HosenLocation.ZairaisenKbn, MR_HosenLocation.DenshiShoninHyojiFlg, MR_HosenLocation.DefaultBranchCode, MR_HosenLocation.DefaultLocationCode, MR_HosenLocation.PlantCode, MR_HosenLocation.HokanBasho, MR_HosenLocation.TsutatsuKeihatsuKbn, MR_HosenLocation.YosanSekininsha, MR_HosenLocation.TammuLevelPtnCode, MR_HosenLocation.MaintenanceKbn, MR_HosenLocation.HyojiJuni FROM DB_Mst.SCH_Mst.G_Location INNER JOIN DB_Mst.SCH_Mst.G_SystemUseLocation ON G_Location.BranchCode=G_SystemUseLocation.BranchCode AND G_Location.LocationCode=G_SystemUseLocation.LocationCode INNER JOIN DB_Mst.SCH_Mst.MR_HosenLocation ON G_Location.BranchCode=MR_HosenLocation.BranchCode AND G_Location.LocationCode=MR_HosenLocation.LocationCode WHERE G_SystemUseLocation.SystemCode = 'SR' 這個是可以正常執行的,我把它寫在了代碼里,一直以來也沒有問題,程序可以正常工作,可是就在昨天,程序運行到這里的時候,突然就出現了{"The multi-part identifier \"G_Location.BranchCode\" could not be bound.\r\nThe multi-part identifier \"G_SystemUseLocation.BranchCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.LocationCode\" could not be bound.\r\nThe multi-part identifier \"G_SystemUseLocation.LocationCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.BranchCode\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.BranchCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.LocationCode\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.LocationCode\" could not be bound.\r\nThe multi-part identifier \"G_SystemUseLocation.SystemCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.BranchCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.LocationCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.LocationName\" could not be bound.\r\nThe multi-part identifier \"G_Location.LocationNickName\" could not be bound.\r\nThe multi-part identifier \"G_Location.LocalSectionCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.CompanyCode\" could not be bound.\r\nThe multi-part identifier \"G_Location.GyoumuInfo\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.MenuPtnId\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.ShinkansenKbn\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.ZairaisenKbn\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.DenshiShoninHyojiFlg\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.DefaultBranchCode\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.DefaultLocationCode\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.PlantCode\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.HokanBasho\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.TsutatsuKeihatsuKbn\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.YosanSekininsha\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.TammuLevelPtnCode\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.MaintenanceKbn\" could not be bound.\r\nThe multi-part identifier \"MR_HosenLocation.HyojiJuni\" could not be bound."} 的錯誤,我調查了之后,將select的字段和where中的條件都加上了DB名和Schema名的前綴"DB_Mst.SCH_Mst.",再次執行到這里的時候就可以正常通過,我很疑惑,為什么在查詢分析器中可以正常執行呢,還有為什么以前沒有出現這樣的錯誤,就是現在,在其它的機器上,程序執行到這里也是一樣沒有異常的,我以為是DB服務器的配置出了問題,可是在連接不同的DB服務器是也還是這樣,只是這一臺測試機不通過,其它機器沒問題;因為這部分程序已經提交了,客戶那里沒有出現這樣的問題,我不便再去修改sql了,請問,這些問題是sql語句本身的錯誤嗎,還有沒有其它的原因,急盼賜知,不勝感激!
...全文
545 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
jfjy_0 2008-11-12
  • 打赏
  • 举报
回复
奇怪的问题
xu_yunpeng 2008-11-12
  • 打赏
  • 举报
回复
代码没问题,这个程序都已经提交了,其它机子执行是没错的
you_tube 2008-11-12
  • 打赏
  • 举报
回复
检查一下你代码写得有错不??
xu_yunpeng 2008-11-12
  • 打赏
  • 举报
回复
是不是有人动了数据库的结构?
===============================
没有,数据库结构没问题,sql在查询分析器中可以正常执行的
nzperfect 2008-11-12
  • 打赏
  • 举报
回复
是不是有人动了数据库的结构?
xu_yunpeng 2008-11-12
  • 打赏
  • 举报
回复
要统一,打错了。
=====================
没错,这个我也知道,可是这条sql我现在没权限修改,它在其它地方执行的时候也是没有问题的,就是很突然的在这个机子上跑不过,我想除了sql语句本身,是不是还有其它问题?
fcuandy 2008-11-12
  • 打赏
  • 举报
回复
语句写的这么不规范,应该报错。

就算语法没错,也应该报出来,纠正坏习惯^^
dobear_0922 2008-11-12
  • 打赏
  • 举报
回复
看看,没遇到过,帮顶。
fcuandy 2008-11-12
  • 打赏
  • 举报
回复
要统一,打错了。
fcuandy 2008-11-12
  • 打赏
  • 举报
回复
SELECT    G_Location.BranchCode, 
G_Location.LocationCode,
G_Location.LocationName,
G_Location.LocationNickName,
G_Location.LocalSectionCode,
G_Location.CompanyCode,
G_Location.GyoumuInfo,
MR_HosenLocation.MenuPtnId,
MR_HosenLocation.ShinkansenKbn,
MR_HosenLocation.ZairaisenKbn,
MR_HosenLocation.DenshiShoninHyojiFlg,
MR_HosenLocation.DefaultBranchCode,
MR_HosenLocation.DefaultLocationCode,
MR_HosenLocation.PlantCode,
MR_HosenLocation.HokanBasho,
MR_HosenLocation.TsutatsuKeihatsuKbn,
MR_HosenLocation.YosanSekininsha,
MR_HosenLocation.TammuLevelPtnCode,
MR_HosenLocation.MaintenanceKbn,
MR_HosenLocation.HyojiJuni
FROM DB_Mst.SCH_Mst.G_Location
INNER JOIN DB_Mst.SCH_Mst.G_SystemUseLocation
ON G_Location.BranchCode=G_SystemUseLocation.BranchCode
AND G_Location.LocationCode=G_SystemUseLocation.LocationCode
INNER JOIN DB_Mst.SCH_Mst.MR_HosenLocation
ON G_Location.BranchCode=MR_HosenLocation.BranchCode
AND G_Location.LocationCode=MR_HosenLocation.LocationCode
WHERE G_SystemUseLocation.SystemCode = 'SR'



语在写的时候最好一至。

select db1..ta.x,db2..tb.y from db1..ta inner join db2..tb on db1..ta.id=db2..tb.id

select a.x,b.y from db1..ta a inner join db2..tb b on a.id=b.id
而不要写成:

select db1..ta.x,db2..tb.y from db1..ta inner join db2..tb on ta.id=tb.id


即,写法要统计
xu_yunpeng 2008-11-12
  • 打赏
  • 举报
回复
你的编译器是什么版本
有没有 字符集冲突

===========================
没明白,能详细点吗
tianhuo_soft 2008-11-12
  • 打赏
  • 举报
回复
你的编译器是什么版本
有没有 字符集冲突
liangCK 2008-11-12
  • 打赏
  • 举报
回复
.......

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧