Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query Help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

101 Posts

Posted - 07/24/2006 :  17:11:12  Show Profile  Reply with Quote

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


Almighty SQL Goddess

38200 Posts

Posted - 07/24/2006 :  17:13:59  Show Profile  Visit tkizer's Homepage  Reply with Quote
INSERT INTO tblinvoice(fkGroup, fkAgency, fkAdvertiser)
SELECT DISTINCT fkGroup, fkAgency, fkAdvertiser
FROM tblSpot

Tara Kizer
Go to Top of Page

Flowing Fount of Yak Knowledge

4110 Posts

Posted - 07/24/2006 :  22:47:00  Show Profile  Send jen a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000