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
 SQL Server Development (2000)
 need to compare 2 tables and then insert into 1

Author  Topic 

caroline
Starting Member

3 Posts

Posted - 2005-06-21 : 16:06:18
Hello,
I have two tables and need to import some records from second table to first table.

First table contains three fields last Name and Home address and tel. (But tel fields are blank in this table.)
Second table contains two fields::last name ,tel.

Now i need to join them and then compare last name field in both tables , if in Table #2 if i find a last name which is in first table then i need to pick up tel# of that last name and put it in first table where last name is there in first table.

So something like i need can you please let me know exact querry.

Select from lastname.Table2 and now compare with lastname.Table1 if equals then insert tel.table2 into tel.table1
and then loop the whole records.

I just know the concept but can't write this line in SQL statement for Access.
Please help
thanks

caroline
Starting Member

3 Posts

Posted - 2005-06-21 : 16:13:09
Instead of Access , i need this for MS SQL server 2000. Microsoft SQL Server , Oops sorry my fault. Can you please give this SQL querry for Microsoft SQL Server . thanks
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-06-21 : 16:13:31
UPDATE t1 SET t1.phonenumb = t2.phonenumb
FROM table1 t1 JOIN table2 t2 ON t2.LastName = t1.LastName


Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

caroline
Starting Member

3 Posts

Posted - 2005-06-21 : 16:47:59
Thank you jhermiz
This is the best forum i have seen, so fast i got the reply and wow i love it. i guess now i will learn MS SQL in depth as now i know i can get help from helpful people here. Great, i am yr fan from now..
thanks again.
Go to Top of Page
   

- Advertisement -