Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bmann
Starting Member
1 Post |
Posted - 2008-07-16 : 04:08:20
|
| Hello,I am running the following query in SQL 2005. And get the error:Msg 4104, Level 16, State 1, Line 1The multi-part identifier "ServicePointChannel.SpcNodeid" could not be bound.selecta.AccountID,a.Status as AccountStatus,Reading.NodeID,ReadingPeriod.StartTime,ReadingPeriod.EndTime--,Reading.ReceivedTime,Reading.DataValue--,dbo.fn_DecodeStatus(Reading.Status) AS Statusfrom nodeINNER JOIN Reading ON ServicePointChannel.SpcNodeid = Reading.nodeidINNER JOIN ReadingPeriod ON ServicePointChannel.SpcNodeid = ReadingPeriod.SpcnodeidINNER JOIN ServicePointChannel on ServicePointChannel.NodeKey = node.NodeKeyINNER JOIN NodeLink on NodeLink.RightNodeKey = ServicePointChannel.NodeKeyINNER JOIN ServicePoint ON ServicePoint.NodeKey = NodeLink.LeftNodeKeyINNER JOIN codevalue cv on servicepoint.commoditytypekey = cv.codevaluekey INNER JOIN (selectspc.NodeKey as SPCNodeKey,spc.ServicePointChannelKey,spc.SpcNodeid,ic.IntervalLength,'Interval' as ChannelType,ic.ChannelNumber,ic.NodeKey as ChannelNodeKey,nl.NodeLinkKey,ic.EffectiveStartDate as ChannelEffectiveStartDate,ic.EffectiveEndDate as ChannelEffectiveEndDate,nl.EffectiveStartDate as NodeLinkEffectiveStartDate,nl.EffectiveEndDate as NodeLinkEffectiveEndDatefromServicePointChannel spcjoin NodeLink nl on spc.NodeKey = nl.LeftNodeKeyjoin NodeLinkReason nlr on nl.NodeLinkReasonKey = nlr.NodeLinkReasonKey and nlr.ReferenceID = 'ServicePointChannel_To_IntervalChannel'join IntervalChannel ic on nl.RightNodeKey = ic.NodeKey) as ChannelJoin on ServicePointChannel.ServicePointChannelKey = ChannelJoin.ServicePointChannelKeyleft outer join NodeLink nl2 on nl2.RightNodeKey = ServicePointChannel.NodeKey and nl2.NodeLinkReasonKey in (select NodeLinkReasonKey from NodeLinkReason where ReferenceID = 'AccountServicePointChannel_To_ServicePointChannel')left outer join AccountServicePointChannel aspc on nl2.LeftNodeKey = aspc.NodeKeyleft outer join NodeLink nl3 on nl3.RightNodeKey = aspc.NodeKey and nl3.NodeLinkReasonKey in (select NodeLinkReasonKey from NodeLinkReason where ReferenceID = 'Account_To_AccountServicePointChannel')left outer join Account a on a.NodeKey = nl3.LeftNodeKeyorder by a.accountid, starttime ascCan someone check this out because i'm a bit lost. |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-07-16 : 04:29:38
|
quote: Originally posted by bmann Hello,I am running the following query in SQL 2005. And get the error:Msg 4104, Level 16, State 1, Line 1The multi-part identifier "ServicePointChannel.SpcNodeid" could not be bound.selecta.AccountID,a.Status as AccountStatus,Reading.NodeID,ReadingPeriod.StartTime,ReadingPeriod.EndTime--,Reading.ReceivedTime,Reading.DataValue--,dbo.fn_DecodeStatus(Reading.Status) AS Statusfrom nodeINNER JOIN Reading ON ServicePointChannel.SpcNodeid = Reading.nodeidINNER JOIN ReadingPeriod ON ServicePointChannel.SpcNodeid = ReadingPeriod.SpcnodeidINNER JOIN ServicePointChannel on ServicePointChannel.NodeKey = node.NodeKeyINNER JOIN NodeLink on NodeLink.RightNodeKey = ServicePointChannel.NodeKeyINNER JOIN ServicePoint ON ServicePoint.NodeKey = NodeLink.LeftNodeKeyINNER JOIN codevalue cv on servicepoint.commoditytypekey = cv.codevaluekey INNER JOIN (selectspc.NodeKey as SPCNodeKey,spc.ServicePointChannelKey,spc.SpcNodeid,ic.IntervalLength,'Interval' as ChannelType,ic.ChannelNumber,ic.NodeKey as ChannelNodeKey,nl.NodeLinkKey,ic.EffectiveStartDate as ChannelEffectiveStartDate,ic.EffectiveEndDate as ChannelEffectiveEndDate,nl.EffectiveStartDate as NodeLinkEffectiveStartDate,nl.EffectiveEndDate as NodeLinkEffectiveEndDatefromServicePointChannel spcjoin NodeLink nl on spc.NodeKey = nl.LeftNodeKeyjoin NodeLinkReason nlr on nl.NodeLinkReasonKey = nlr.NodeLinkReasonKey and nlr.ReferenceID = 'ServicePointChannel_To_IntervalChannel'join IntervalChannel ic on nl.RightNodeKey = ic.NodeKey) as ChannelJoin on ServicePointChannel.ServicePointChannelKey = ChannelJoin.ServicePointChannelKeyleft outer join NodeLink nl2 on nl2.RightNodeKey = ServicePointChannel.NodeKey and nl2.NodeLinkReasonKey in (select NodeLinkReasonKey from NodeLinkReason where ReferenceID = 'AccountServicePointChannel_To_ServicePointChannel')left outer join AccountServicePointChannel aspc on nl2.LeftNodeKey = aspc.NodeKeyleft outer join NodeLink nl3 on nl3.RightNodeKey = aspc.NodeKey and nl3.NodeLinkReasonKey in (select NodeLinkReasonKey from NodeLinkReason where ReferenceID = 'Account_To_AccountServicePointChannel')left outer join Account a on a.NodeKey = nl3.LeftNodeKeyorder by a.accountid, starttime ascCan someone check this out because i'm a bit lost.
look at your first join....? you're joining NODE to READING but your join condition references a different table??Em |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-16 : 05:18:28
|
Cleaner code.SELECT a.AccountID, a.Status AS AccountStatus, Reading.NodeID, ReadingPeriod.StartTime, ReadingPeriod.EndTime, Reading.DataValueFROM NodeINNER JOIN ServicePointChannel ON ServicePointChannel.NodeKey = Node.NodeKeyINNER JOIN Reading ON Reading.NodeID = ServicePointChannel.SpcNodeIDINNER JOIN ReadingPeriod ON ReadingPeriod.SpcNodeID = ServicePointChannel.SpcNodeIDINNER JOIN NodeLink ON NodeLink.RightNodeKey = ServicePointChannel.NodeKeyINNER JOIN ServicePoint ON ServicePoint.NodeKey = NodeLink.LeftNodeKeyINNER JOIN CodeValue AS cv ON cv.CodeValueKey = ServicePoint.CommodityTypeKeyINNER JOIN ( SELECT spc.ServicePointChannelKey FROM ServicePointChannel AS spc INNER JOIN NodeLink AS nl ON nl.LeftNodeKey = spc.NodeKey INNER JOIN NodeLinkReason AS nlr ON nlr.NodeLinkReasonKey = nl.NodeLinkReasonKey INNER JOIN IntervalChannel AS ic on ic.NodeKey = nl.RightNodeKey WHERE nlr.ReferenceID = 'ServicePointChannel_To_IntervalChannel' ) AS cj ON cj.ServicePointChannelKey = ServicePointChannel.ServicePointChannelKeyLEFT JOIN ( SELECT nl.RightNodeKey, nl.LeftNodeKey FROM NodeLink AS nl INNER JOIN NodeLinkReason AS nlr ON nlr.NodeLinkReasonKey = nl.NodeLinkReasonKey WHERE nlr.ReferenceID = 'AccountServicePointChannel_To_ServicePointChannel' ) AS nl2 ON nl2.RightNodeKey = ServicePointChannel.NodeKeyLEFT JOIN AccountServicePointChannel AS aspc ON aspc.NodeKey = nl2.LeftNodeKeyLEFT JOIN ( SELECT nl.RightNodeKey, nl.LeftNodeKey FROM NodeLink AS nl INNER JOIN NodeLinkReason AS nlr ON nlr.NodeLinkReasonKey = nl.NodeLinkReasonKey WHERE nlr.ReferenceID = 'Account_To_AccountServicePointChannel' ) AS nl3 ON nl3.RightNodeKey = aspc.NodeKeyLEFT JOIN Account AS a ON a.NodeKey = nl3.LeftNodeKeyORDER BY a.AccountID, ReadingPeriod.StartTime E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|