| Author |
Topic |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-04 : 05:05:48
|
| I want to repair the following Insert Command.insert into emp_master (emp_id,first_name,passport_no) select ?ep_id,?fr_name,?pass_p from johu1 where ?RTRIM(ep_id) not in RTRIM(emp_id)ThanksParamu @ PARANTHAMAN |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-04 : 05:15:34
|
| do u want thisinsert into emp_master (emp_id,first_name,passport_no) select ?ep_id,?fr_name,?pass_p from johu1 where RTRIM(ep_id) not in (select RTRIM(emp_id) from emp_master )insert into emp_master (emp_id,first_name,passport_no) select ?ep_id,?fr_name,?pass_p from johu1 where not exists (select * from emp_master where RTRIM(emp_id) = rtrim(ep_id)) |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-04 : 07:38:50
|
| But Iam having SQL SERVER 2005Paramu @ PARANTHAMAN |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-04 : 07:58:48
|
| it will work in sql server 2005insert into table (col1,col2,...) selectcol1,col2,.... from targettable twhere not exitst (select * from table where col1 = t.col1) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-04 : 08:28:22
|
quote: Originally posted by paramu I want to repair the following Insert Command.insert into emp_master (emp_id,first_name,passport_no) select ?ep_id,?fr_name,?pass_p from johu1 where ?RTRIM(ep_id) not in RTRIM(emp_id)ThanksParamu @ PARANTHAMAN
whats the purpose of ? marks before column names? |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-04 : 09:15:36
|
| To bklr: Pls....check & give with confirmed reply. It's not working for me. It's saying error nearer to 'Select' statement. But the first insert into emp_master (emp_id,first_name,passport_no) select ep_id,fr_name,pass_p from johu1 where RTRIM(ep_id) not in (select RTRIM(emp_id)from emp_master )is executed but [0] rows affected........So please check ..............PTS: just the ? for using it from VFP9 _ But now I check directly in SQL SERVER 2005.Paramu @ PARANTHAMAN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-04 : 09:19:41
|
| [code]insert into emp_master (emp_id,first_name,passport_no) select j.ep_id,j.fr_name,j.pass_p from johu1 jwhere not exists (select 1 from emp_master where RTRIM(emp_id) = rtrim(j.ep_id))[/code] |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-04 : 09:23:26
|
| just try this i have given u some sample datadeclare @t table (col1 int, col2 varchar(20))insert @tselect 8244,'C' union allselect 8504,'C' union allselect 8554,'C'declare @temp table(col1 int,col2 varchar(32))insert into @tempselect 8244,'sampledata'insert into @temp (col1,col2) selectcol1,col2 from @t twhere not exists (select * from @temp where col1 = t.col1)select * from @tempinsert into @temp (col1,col2) selectcol1,col2 from @t twhere col1 not in (select col1 from @temp )select * from @tempIn my previous query its just spelling mistake exitst as 'exists' (typing mistake) |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-04 : 09:55:14
|
| Fine...!!!!! , Thanks & Best Wishes & AppreciatedParamu @ PARANTHAMAN |
 |
|
|
|