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 2000 Forums
 Transact-SQL (2000)
 Update on Table variable

Author  Topic 

anandc
Starting Member

20 Posts

Posted - 2005-12-30 : 08:20:21
I am using a table variable and updating it from another table. But some of the column names in my table variable are same as the table from which i am updating.
I am using the below code

UPDATE @tblCalcClearingCharge
SET IntClrChrgID = a.IntClrChrgID,
AgencyFee = ISNULL(a.AgencyFee,0),
PrincipalFee = ISNULL(a.PrincipalFee,0),
FROM tm_ClrChrgConfigFlat a
WHERE a.intRepID = Rep_ID

I have even tried using the below code, but it does not work either...

UPDATE @tblCalcClearingCharge
SET @tblCalcClearingCharge.IntClrChrgID = a.IntClrChrgID,
@tblCalcClearingCharge.AgencyFee = ISNULL(a.AgencyFee,0),
@tblCalcClearingCharge.PrincipalFee = ISNULL(a.PrincipalFee,0),
FROM tm_ClrChrgConfigFlat a
WHERE a.intRepID = Rep_ID

Is there any solution to this, besides changing the column names in my table variable.

Thanks

- Anand

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-30 : 08:31:05
Try this

UPDATE T
SET T.IntClrChrgID = a.IntClrChrgID,
T.AgencyFee = ISNULL(a.AgencyFee,0),
T.PrincipalFee = ISNULL(a.PrincipalFee,0),
FROM @tblCalcClearingCharge T inner join tm_ClrChrgConfigFlat a
on T.intRepID = a.Rep_ID


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -