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)
 Query Help

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'
union
select 100,'01-Aug-2010'
union
select 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 case
the two records of output are
100--Aug-2010
101--Aug-2010

Please guuide me.
TIA.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-24 : 10:03:24
[code]select p.*
FROm @psd p
left join @mpsd n
on npsd.EID=p.EID
WHERE n.EID is null
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

learntsql

524 Posts

Posted - 2010-08-24 : 10:06:52
Visakh thanks for quick reply,
but in output i want even 100--Aug-2010
because its new record.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-24 : 10:08:58
[code]select p.*
FROm @psd p
left join @mpsd n
on n.EID=p.EID
and n.MP = p.MP
WHERE n.EID is null
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

learntsql

524 Posts

Posted - 2010-08-24 : 10:10:29
Thankq very much.
sorry may be it was simple.
Go to Top of Page

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 MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -