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 2008 Forums
 Transact-SQL (2008)
 using not exists to return the results

Author  Topic 

ppatel112
Starting Member

35 Posts

Posted - 2013-11-12 : 00:26:19
My Query below returns all the data from arsap and the intersection between ARSAP and users table

select NAMEEMPL from SAMINC.dbo.ARSAP LEFT OUTER JOIN
dbo.Users ON NAMEEMPL = User_FirstName + ' ' + User_LastName Collate Latin1_General_CI_AS

what i need to do is to only return the data that is not matched from ARSAP table to users table above.

any help will be much appreciated.

regards

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-12 : 00:42:30
[code]select NAMEEMPL
from SAMINC.dbo.ARSAP
LEFT OUTER JOIN dbo.Users
ON NAMEEMPL = User_FirstName + ' ' + User_LastName Collate Latin1_General_CI_AS
WHERE User_FirstName IS NULL[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-12 : 01:53:36
[code]
select NAMEEMPL from SAMINC.dbo.ARSAP
WHERE NOT EXISTS (SELECT 1
FROM dbo.Users
WHERE NAMEEMPL = User_FirstName + ' ' + User_LastName Collate Latin1_General_CI_AS
)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -