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)
 Updating

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-13 : 08:32:25
Nkagi writes "Dear All,


This might sound like a stupid question but I will ask it anyway, by the way I'm still a beginner so please bear with me.I am trying to update a table called erven with the statement below, but everytime I excecute it I get an error.(Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '('.)
update erven set (ErfNr, suburb, Owner, street, stno) = (select
Col003 as ErfNo, suburb,
Col002 as Owner, col004 as street, stno as strno
from import where accno = erfaccountno);

I trie changing it to the following but it still produces errors (erver: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'select'.
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'select'.
Server: Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'select'.
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'select'.):

update erven set ErfNr = select Col003 as ErfNo from import,erven where accno = erfaccountno
update erven set suburb = select suburb from import where accno = erfaccountno
update erven set Owner = select Col002 as Owner from import where accno = erfaccountno
update erven set street = select col004 as street from import where accno = erfaccountno
update erven set stno = select stno as strno from import where accno = erfaccountno


please help me."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-13 : 09:41:59
Refer this and use the same logic
http://sqlteam.com/forums/topic.asp?TOPIC_ID=50990

EDIT : Instead of Select, Use update statement

Madhivanan

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

- Advertisement -