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 2005 Forums
 Transact-SQL (2005)
 select from table and insert

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-08-03 : 08:20:11
Hi,

I need to insert into table Results all candidates from table Candidates. However, if a candidate_id already exists in table Results then i mustn't insert that candidate.
How can i do that?

Thanks

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-03 : 08:32:41
insert into all_candidates(columns)
select columns from candidate as c
where not exists(select * from all_candidate where candidate_id =c.candidate_id )


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -