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
 General SQL Server Forums
 New to SQL Server Programming
 insert record into table from another table

Author  Topic 

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-02-08 : 15:54:36
Greeting All, Again I stuck from foxpro into sql.
could use some help.

I have 2 tables, Contact and Service.
In the contact table I have an ID number
that I would to insert into the Service table
based on the Service table user name.

I cant use a Foxpro replace all command with some
function attached to the script. I cant seem to find
a SQL version of what I would like to do.

So here is my layout. If someone might be able to point
me in a direction, I would be greatful


Contact Table "grid is the auto id field"
grid, Anumber, Name, Address

Service Table
grid, Anumber, Name, Address


service.name = contact.name add 'anumber' from contact table to service table where service.name lives.

I will keep looking on my own. any help would be great
Thanx..










recontrasalo
Starting Member

12 Posts

Posted - 2008-02-08 : 16:03:00
insert service (idnumber)
select a.idnumber from service a
join contact b
on a.username = b.username
Go to Top of Page

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-02-08 : 16:09:10
Than you,
I was getting close..This is what I had in mind

SELECT anumber
FROM contact a
LEFT OUTER JOIN service b
ON b.name=a.name

Insert ??????

Go to Top of Page
   

- Advertisement -