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)
 SQL Query Help

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-07-24 : 17:11:12
Guys,

I have a query from a table name called "tblspot",

SELECT DISTINCT fkGroup, fkAgency, fkAdvertiser FROM tblSpot

what i want is i want to insert this 'fkagency' and 'fkadvertiser' into another table called "tblinvoice" which already has fields with "fkagency" and "fkadvertiser"

Can you guys help me with the query

Thanks,

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-24 : 17:13:59
INSERT INTO tblinvoice(fkGroup, fkAgency, fkAdvertiser)
SELECT DISTINCT fkGroup, fkAgency, fkAdvertiser
FROM tblSpot

Tara Kizer
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-07-24 : 22:47:00
insert into tblInvoice(fkagency,fkadvertiser,...)
select fkagency,fkadvertiser
from (select distinct fkgroup,fkagency,fkadvertiser from tblspot) a


or do you wish to check for existence of those field values first and prevent duplicate rows?

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -