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
 SQL Server Development (2000)
 sql update

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-04-26 : 06:15:50
What is wrong with this query please?
declare @tblSpotRateCodes table
(
ID int identity(1, 1),
SpotRateCode varchar(6) --length of 6 because spotRate code is combined of two currencies...
)

declare @tblSpotRateValues table
(
ID int identity(1, 1),
CurrencyPairID int null,
BID decimal(20, 15) null,
ASK decimal(20, 15) null,
MID decimal(20, 15) null
)

update
@tblSpotRateValues inner join @tblSpotRateCodes
on @tblSpotRateValues.ID = @tblSpotRateCodes.ID
set
@tblSpotRateValues.CurrencyPairID = @tblSpotRateCodes.SpotRateCode


ERROR:
Msg 156, Level 15, State 1, Line 17
Incorrect syntax near the keyword 'inner'.
Msg 137, Level 15, State 1, Line 20
Must declare the scalar variable "@tblSpotRateValues".

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-26 : 06:25:43
Learn to not think MS Access SQL queries.
Learn to think MS SQL Server.
update		t
set t.CurrencyPairID = u.SpotRateCode
from @tblSpotRateValues as t
inner join @tblSpotRateCodes as u on u.ID = t.ID


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-04-26 : 06:34:11
Thanks
Go to Top of Page
   

- Advertisement -