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)
 update multiple records

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-01 : 08:33:34
hello,
I have a problem with an update query.

when I run :
Select contact.name, company.name
from contact
inner join company on company.id=contact.companyid
where company = 'test'

I am displayed 3 rows.

when I run :

UPDATE contact
SET contact.name = company.name
from contact
inner join company on company.id=contact.companyid
where company = 'test'

I only update 1 row.

how can I update all the rows ?
what am I doing wrong here ?

nice one guys,
Jamie

mr_mist
Grunnio

1870 Posts

Posted - 2004-07-01 : 09:23:15
You probably have 3 rows in company, but only one match in contact.

-------
Moo. :)
Go to Top of Page

sujeetnatarajan
Starting Member

1 Post

Posted - 2004-07-02 : 07:04:58
quote:
Originally posted by jamie

hello,
I have a problem with an update query.

when I run :
Select contact.name, company.name
from contact
inner join company on company.id=contact.companyid
where company = 'test'

I am displayed 3 rows.

when I run :

UPDATE contact
SET contact.name = company.name
from contact
inner join company on company.id=contact.companyid
where company = 'test'

I only update 1 row.

how can I update all the rows ?
what am I doing wrong here ?

nice one guys,
Jamie




hi frnd
try this
UPDATE contact
SET contact.name = company.name
from contact
inner join company on company.id=contact.companyid
where company like '%test%'
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-02 : 07:19:58
hi,
I think the problem is what mr mist has suggested.
I need to rewrite my query to only display the one related value, instead of all company values.

thanks
Go to Top of Page
   

- Advertisement -