update table problem 
Author Message
 update table problem

I have SQL Server 2000 database.
I have 2 tables with the same fields and structure (table1, table2).
Table1 has all the records and table2 has only several selected records from
table1.
I would like to update all the records in table1 that apears in table2. I
would like to update a certain field (field1) to a constant value (const1).
How do I do that ?
Thanks for your time




Fri, 16 Apr 2004 15:53:03 GMT  
 update table problem
UPDATE table1 SET field1 = 3,
        field2 = table2.field2
FROM table1, table2
WHERE table1.id = table2.id


Quote:
> I have SQL Server 2000 database.
> I have 2 tables with the same fields and structure (table1, table2).
> Table1 has all the records and table2 has only several selected records
from
> table1.
> I would like to update all the records in table1 that apears in table2. I
> would like to update a certain field (field1) to a constant value
(const1).
> How do I do that ?
> Thanks for your time





Fri, 16 Apr 2004 23:17:25 GMT  
 update table problem
*** post for FREE via your newsreader at post.newsfeeds.com ***

Try this.

update table1
set field1 = const1
from table1 t1
        innerjoin table2 t2 on  t1.fld=t2.fld

Steve


Quote:
> I have SQL Server 2000 database.
> I have 2 tables with the same fields and structure (table1, table2).
> Table1 has all the records and table2 has only several selected records
from
> table1.
> I would like to update all the records in table1 that apears in table2. I
> would like to update a certain field (field1) to a constant value
(const1).
> How do I do that ?
> Thanks for your time



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 90,000 Newsgroups - 16 Different Servers! =-----


Fri, 16 Apr 2004 23:20:24 GMT  
 update table problem

Quote:
>         innerjoin table2 t2 on  t1.fld=t2.fld

Missing a space between inner and join

www.aspfaq.com



Sat, 17 Apr 2004 00:31:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Create followed by Update Table Problem

2. Update table problem

3. DBGrid not updating table problem in VB5

4. update table problem

5. Problem With DAO Recordset Table Update

6. ADO.NET Update Source Table Problem

7. ADO.NET Update Source Tables Problem

8. Vb6: Problems with .DBF table Update

9. DBCombo problems - Can't get it to update source table

10. Problem updating Table Fields (Program Flow)

11. PROBLEM: Accessing Foxpro table(delete, update, insert)

12. problem with a table update, please help

 

 
Powered by phpBB® Forum Software