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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 join problem

Author  Topic 

fan2005
Yak Posting Veteran

85 Posts

Posted - 2011-01-31 : 03:10:24
hi,
this query fails to these errors
The multi-part identifier "arc87.balance" could not be bound.
The multi-part identifier "arc87.balance" could not be bound.
how can i fix it
thanks for fast reply

CREATE CLUSTERED INDEX IXC_Transaction_AccountID_Tarikh_TransactionID
ON TransactionDetail (AccountID, tarikh, TransactionID)

DECLARE @PrevAccountID bigINT = 0
DECLARE @AccountRunningTotal decimal(38,0) = 0

UPDATE TransactionDetail SET
@AccountRunningTotal = t.balance = CASE
WHEN t.AccountID = @PrevAccountID THEN @AccountRunningTotal + t.gardesh +arc87.balance
ELSE t.gardesh+arc87.balance
END,
@PrevAccountID=t.AccountID
select * from TransactionDetail t
inner join arc87 on
arc87.accountId=t.accountID


MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-31 : 04:16:24
Check the syntax issues
There are two different statements in the given query
First Statement

UPDATE TransactionDetail SET
@AccountRunningTotal = t.balance = CASE --incorrect assignment
WHEN t.AccountID = @PrevAccountID THEN @AccountRunningTotal + t.gardesh +arc87.balance --Arc87 is not defined any here in this update statement .. so how can you refer it?
ELSE t.gardesh+arc87.balance
END,
@PrevAccountID=t.AccountID



Perhaps you forgot to remove the "Select *" from the above statment :)

Second Statement
select * from TransactionDetail t
inner join arc87 on
arc87.accountId=t.accountID
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-01-31 : 05:50:16
[code]
CREATE CLUSTERED INDEX IXC_Transaction_AccountID_Tarikh_TransactionID
ON TransactionDetail (AccountID, tarikh, TransactionID)

DECLARE @PrevAccountID bigINT = 0
DECLARE @AccountRunningTotal decimal(38,0) = 0

UPDATE TD SET
@AccountRunningTotal = TD.balance = CASE
WHEN TD.AccountID = @PrevAccountID THEN @AccountRunningTotal + TD.gardesh +arc87.balance
ELSE TD.gardesh+arc87.balance
END,
@PrevAccountID=TD.AccountID
from TransactionDetail TD inner join arc87 on TD.accountId=arc87.accountId

select * from TransactionDetail t
inner join arc87 on
arc87.accountId=t.accountID

[/code]

PBUH

Go to Top of Page

fan2005
Yak Posting Veteran

85 Posts

Posted - 2011-01-31 : 14:34:05
thanks i was in rush doing this.
i mad a big mistake
Go to Top of Page
   

- Advertisement -