SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

saidev
Posting Yak Master

101 Posts

Posted - 07/24/2006 :  17:11:12  Show Profile  Reply with Quote
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

USA
37127 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

jen
Flowing Fount of Yak Knowledge

Sweden
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  
 New 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.05 seconds. Powered By: Snitz Forums 2000