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)
 the problem using alias within update query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-08-30 : 06:16:56
Irena writes "helo!
I have a problem while using alias in "UPDATE" query
i have a table Books and want to write such a query:
UPDATE Books B
SET Max_Time =
(SELECT MAX(Max_Time) FROM Books
WHERE Faculty = B.Faculty);
but get a problem "Incorrect syntax near 'B'."(Books is legal table,I run queries on it)
Can You help me please ...what is the problem can`t I use alias in "UPDATE" query?
Thank You "

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-30 : 07:29:58
this should do it :
UPDATE B
SET Max_Time = (SELECT MAX(Max_Time) FROM Books
WHERE Faculty = B.Faculty)
FROM Books B

Go with the flow & have fun! Else fight the flow :)
Go to Top of Page
   

- Advertisement -