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 2005 Forums
 Transact-SQL (2005)
 Update with inner join

Author  Topic 

lucsky8
Posting Yak Master

105 Posts

Posted - 2009-06-03 : 08:19:11
I have 2 table i'am trying to take some data in tblTest and put it in tblResultatPolyMinistere.

I use :

UPDATE		
tblResultatPolyMinistere as tm
INNER JOIN tblTest as t
ON t.NDI = tm.intEleveId
SET tm.intH1 = t.H1,
tm.intH2 = t.H2,
tm.intH3 = t.H3,
tm.intC1 = t.C1,
tm.intC2 = t.C2,
tm.intC3 = t.C3,
tm.RH1 = t.RH1,
tm.RH2 = t.RH2,
tm.RH3 = t.RH3,
tm.RC1 = t.RC1,
tm.RC2 = t.RC2,
tm.RC3 = t.RC3
WHERE tm.strDateExamen = '200806'
and t.AAAAMM = '200806'
and t.cours = 10332
and tm.intCoursId = 10332


When i run it i get :

Incorrect syntax near the keyword 'as'.

I can't find where the error
Is it my santax?
Tks in adavance

jasraja
Starting Member

22 Posts

Posted - 2009-06-03 : 08:24:41
correct syntax would be:

Update TableA
Set Column1 = B.ColumnA
from TableA A inner join TableB B
on (join condition)

Go to Top of Page

lucsky8
Posting Yak Master

105 Posts

Posted - 2009-06-03 : 08:34:09
quote:
Originally posted by jasraja

correct syntax would be:

Update TableA
Set Column1 = B.ColumnA
from TableA A inner join TableB B
on (join condition)





Tks it wotk had to remove my fist as t to
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-03 : 13:21:55
either give tablename or alias not both with UPDATE

ie. either UPDATE tblResultatPolyMinistere

OR
UPDATE tm


Go to Top of Page
   

- Advertisement -