select a.Branch_Id,(select Branch_name from sql.ut.dbo.BranchMap where Branch_Id=a.Branch_Id) as Branch_name,(
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from sql.ut.dbo.MelcoTrafficDay20080118 where ST18+ST20<>0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from sql.ut.dbo.SanyoTrafficDay20080118 where ST20+ST22<>0
group by Branch_Id
) d where Branch_Id=a.Branch_Id
group by Branch_Id
) as dhl
from (
select Branch_Id,sum(convert(float,ST19)) as z1 from sql.ut.dbo.MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from sql.ut.dbo.SanyoTrafficDay20080118
group by Branch_Id
) a group by Branch_Id
这是我的一个sql 语句,在本地运行远程连接的数据库sql.ut.dbo出现这样的错误服务器: 消息 207,级别 16,状态 3,行 1
列名 'Union1012' 无效。
服务器: 消息 8180,级别 16,状态 1,行 1
未能准备语句。
但在远程连接的数据库上运行
select a.Branch_Id,(select Branch_name from BranchMap where Branch_Id=a.Branch_Id) as Branch_name,(
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from MelcoTrafficDay20080118 where ST18+ST20<>0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from SanyoTrafficDay20080118 where ST20+ST22<>0
group by Branch_Id
) d where Branch_Id=a.Branch_Id
group by Branch_Id
) as dhl
from (
select Branch_Id,sum(convert(float,ST19)) as z1 from MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from SanyoTrafficDay20080118
group by Branch_Id
) a group by Branch_Id
则可以正常运行.但是在本地运行
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from sql.ut.dbo.MelcoTrafficDay20080118 where ST18+ST20<>0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from sql.ut.dbo.SanyoTrafficDay20080118 where ST20+ST22<>0
group by Branch_Id
) d 和
select Branch_Id,sum(convert(float,ST19)) as z1 from sql.ut.dbo.MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from sql.ut.dbo.SanyoTrafficDay20080118
group by Branch_Id
则是可以运行的.很是奇怪!谁能给我找出原因是呀!
郁闷!
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from sql.ut.dbo.MelcoTrafficDay20080118 where ST18+ST20<>0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from sql.ut.dbo.SanyoTrafficDay20080118 where ST20+ST22<>0
group by Branch_Id
) d where Branch_Id=a.Branch_Id
group by Branch_Id
) as dhl
from (
select Branch_Id,sum(convert(float,ST19)) as z1 from sql.ut.dbo.MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from sql.ut.dbo.SanyoTrafficDay20080118
group by Branch_Id
) a group by Branch_Id
这是我的一个sql 语句,在本地运行远程连接的数据库sql.ut.dbo出现这样的错误服务器: 消息 207,级别 16,状态 3,行 1
列名 'Union1012' 无效。
服务器: 消息 8180,级别 16,状态 1,行 1
未能准备语句。
但在远程连接的数据库上运行
select a.Branch_Id,(select Branch_name from BranchMap where Branch_Id=a.Branch_Id) as Branch_name,(
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from MelcoTrafficDay20080118 where ST18+ST20<>0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from SanyoTrafficDay20080118 where ST20+ST22<>0
group by Branch_Id
) d where Branch_Id=a.Branch_Id
group by Branch_Id
) as dhl
from (
select Branch_Id,sum(convert(float,ST19)) as z1 from MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from SanyoTrafficDay20080118
group by Branch_Id
) a group by Branch_Id
则可以正常运行.但是在本地运行
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from sql.ut.dbo.MelcoTrafficDay20080118 where ST18+ST20<>0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from sql.ut.dbo.SanyoTrafficDay20080118 where ST20+ST22<>0
group by Branch_Id
) d 和
select Branch_Id,sum(convert(float,ST19)) as z1 from sql.ut.dbo.MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from sql.ut.dbo.SanyoTrafficDay20080118
group by Branch_Id
则是可以运行的.很是奇怪!谁能给我找出原因是呀!
郁闷!
select sum(convert(float,dhl)) as dhl from (
select Branch_Id,sum(convert(float,ST24)/(convert(float,ST18)+convert(float,ST20))) as dhl from sql.ut.dbo.MelcoTrafficDay20080118 where ST18+ST20 <> 0
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST26)/(convert(float,ST20)+convert(float,ST22))) as dhl from sql.ut.dbo.SanyoTrafficDay20080118 where ST20+ST22 <> 0
group by Branch_Id
) d 和
select Branch_Id,sum(convert(float,ST19)) as z1 from sql.ut.dbo.MelcoTrafficDay20080118
group by Branch_Id
union all
select Branch_Id,sum(convert(float,ST21)) as z1 from sql.ut.dbo.SanyoTrafficDay20080118
group by Branch_Id
则是可以运行的.
----------
提示与楼主贴出来的不对哦
列名 'Union1012' 无效。
服务器: 消息 8180,级别 16,状态 1,行 1
未能准备语句。没错,就是提示 这个信息
--查找"Union1012"--字符串