March 22, 2010 at 3:35 pm
Scenario:
Two identical tables from two diferent databases. Table 'A' and table 'B'
I need to get every data not present in table 'A' from table 'B'
This is what i´ve got.
select t2.cotnum, t2.codaux,
t1.cotnum
from softlandsoporte2.softland.nwcotiza t2
left join hermes.lab0708.softland.nwcotiza t1 on t2.cotnum = t1.cotnum
where t1.cotnum is null
March 22, 2010 at 3:40 pm
So what's the problem??
March 22, 2010 at 3:42 pm
Looks fine to me. Is it not producing the desired results?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 23, 2010 at 6:40 am
CirquedeSQLeil (3/22/2010)
Looks fine to me. Is it not producing the desired results?
HI!
Im not getting the results i want.
t2 has less data than t1 and i´m getting no data.
select t2.cotnum, t2.codaux,
t1.cotnum
from softlandsoporte2.softland.nwcotiza t2
left join hermes.lab0708.softland.nwcotiza t1 on t2.cotnum = t1.cotnum
where t1.cotnum is null
thanks in advance.
March 23, 2010 at 7:09 am
igngua (3/23/2010)
CirquedeSQLeil (3/22/2010)
Looks fine to me. Is it not producing the desired results?HI!
Im not getting the results i want.
t2 has less data than t1 and i´m getting no data.
select t2.cotnum, t2.codaux,
t1.cotnum
from softlandsoporte2.softland.nwcotiza t2
left join hermes.lab0708.softland.nwcotiza t1 on t2.cotnum = t1.cotnum
where t1.cotnum is null
thanks in advance.
Please think about what you just said, there is less data in t2 than t1. The query you are running is asking for data in t2 that is not in t1. The fact you are getting no results indicate to me that you are getting the correct results. Change your query to ask for data in t1 that is not in t2 and see what you get.
March 23, 2010 at 10:19 am
thanks!!
it worked!
select t1.cotnum, t1.codaux,
t2.cotnum, t2.codaux
from hermes.lab0708.softland.nwcotiza t1
left join softlandsoporte2.softland.nwcotiza t2 on t1.cotnum = t2.cotnum
where t2.cotnum is null
Now i´ve to update T2 with all the columns from 1 not present in t2
this is what i´ve got.
insert into softlandsoporte2.softland.nwcotiza(t2.CotNum,t2.CodAux,t2.NomCon,t2.CodMon)
select(t1.CotNum,t1.CodAux,t1.NomCon,t1.CodMon)
from hermes.lab0708.softland.nwcotiza t1
left join softlandsoporte2.softland.nwcotiza t2
on t2.cotnum = t1.cotnum
where t2.cotnum is null
I get a sintax error on the blackened line; Incorrect syntax near ','
thanks.
March 23, 2010 at 10:39 am
igngua (3/23/2010)
thanks!!it worked!
select t1.cotnum, t1.codaux,
t2.cotnum, t2.codaux
from hermes.lab0708.softland.nwcotiza t1
left join softlandsoporte2.softland.nwcotiza t2 on t1.cotnum = t2.cotnum
where t2.cotnum is null
Now i´ve to update T2 with all the columns from 1 not present in t2
this is what i´ve got.
insert into softlandsoporte2.softland.nwcotiza(t2.CotNum,t2.CodAux,t2.NomCon,t2.CodMon)
select(t1.CotNum,t1.CodAux,t1.NomCon,t1.CodMon)
from hermes.lab0708.softland.nwcotiza t1
left join softlandsoporte2.softland.nwcotiza t2
on t2.cotnum = t1.cotnum
where t2.cotnum is null
I get a sintax error on the blackened line; Incorrect syntax near ','
thanks.
Take out the parens in the select, not needed.
March 23, 2010 at 10:43 am
igngua (3/23/2010)
thanks!!it worked!
select t1.cotnum, t1.codaux,
t2.cotnum, t2.codaux
from hermes.lab0708.softland.nwcotiza t1
left join softlandsoporte2.softland.nwcotiza t2 on t1.cotnum = t2.cotnum
where t2.cotnum is null
Now i´ve to update T2 with all the columns from 1 not present in t2
this is what i´ve got.
insert into softlandsoporte2.softland.nwcotiza(t2.CotNum,t2.CodAux,t2.NomCon,t2.CodMon)
select(t1.CotNum,t1.CodAux,t1.NomCon,t1.CodMon)
from hermes.lab0708.softland.nwcotiza t1
left join softlandsoporte2.softland.nwcotiza t2
on t2.cotnum = t1.cotnum
where t2.cotnum is null
I get a sintax error on the blackened line; Incorrect syntax near ','
thanks.
Congrats.
And Lynn has the answer about the error.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 23, 2010 at 10:48 am
You may also need to take out the t2. from this line:
insert into softlandsoporte2.softland.nwcotiza(t2.CotNum,t2.CodAux,t2.NomCon,t2.CodMon)
March 23, 2010 at 12:55 pm
Thanks you all!
it worked!
March 23, 2010 at 12:57 pm
igngua (3/23/2010)
Thanks you all!it worked!
You're welcome.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 23, 2010 at 12:59 pm
igngua (3/23/2010)
Thanks you all!it worked!
Thank you for the feedback, and you are welcome.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply