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)
 Trying to do an Update from a select

Author  Topic 

itmaster
Starting Member

28 Posts

Posted - 2013-08-23 : 13:48:42
Hi,
I am trying to do an update and I get error "Incorrect syntax near the keyword 'FROM'." but I am not sure what is wrong.

Can someone please help

My code:

 UPDATE tbl_TestHold 
SET TeamName
FROM tbl_TestHold TH
INNER JOIN dbo.tbllkp_States St
ON TH.State = St.StateAbbreviation
INNER JOIN dbo.lkp_Teams Ts
ON St.StateID = Ts.StateID


Thank you

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2013-08-23 : 13:58:56
TeamName needs to be "TeamName = something".
If you are trying to use a select statement to find the value you will need to rework the code.

djj
Go to Top of Page

itmaster
Starting Member

28 Posts

Posted - 2013-08-23 : 14:13:21
quote:
Originally posted by djj55

TeamName needs to be "TeamName = something".
If you are trying to use a select statement to find the value you will need to rework the code.

djj



I got it to work with youor suggestion.
Thanks
Go to Top of Page

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2013-08-23 : 14:25:33
Glad I could help.

djj
Go to Top of Page

sivadss2007
Starting Member

18 Posts

Posted - 2013-08-28 : 05:32:13
UPDATE tbl_TestHold
SET TeamName = @teamname
FROM tbl_TestHold TH
INNER JOIN dbo.tbllkp_States St
ON TH.State = St.StateAbbreviation
INNER JOIN dbo.lkp_Teams Ts
ON St.StateID = Ts.StateID

P.Siva
Go to Top of Page
   

- Advertisement -