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.
Author |
Topic |
learntsql
524 Posts |
Posted - 2010-08-24 : 10:01:07
|
Hi All,Following is the sample data,declare @psd table(EID int,MP datetime)declare @npsd table(EID int,MP datetime)insert into @psd select 100,'01-Jan-2010'unionselect 100,'01-Aug-2010'unionselect 101,'01-Aug-2010'insert into @npsd select 100,'01-Jan-2010'I have to pickout the records from @psd which are not mapped with @npsd.in this casethe two records of output are100--Aug-2010101--Aug-2010Please guuide me.TIA. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-24 : 10:03:24
|
[code]select p.*FROm @psd pleft join @mpsd non npsd.EID=p.EIDWHERE n.EID is null[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
learntsql
524 Posts |
Posted - 2010-08-24 : 10:06:52
|
Visakh thanks for quick reply,but in output i want even 100--Aug-2010because its new record. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-24 : 10:08:58
|
[code]select p.*FROm @psd pleft join @mpsd non n.EID=p.EIDand n.MP = p.MPWHERE n.EID is null[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
learntsql
524 Posts |
Posted - 2010-08-24 : 10:10:29
|
Thankq very much.sorry may be it was simple. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-24 : 10:11:35
|
it is simple provided you know about joins------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|