SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Generating list of unused staff
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 05/03/2013 :  04:06:24  Show Profile  Reply with Quote
Hi,

I ame currently looking for a way to generate the names of any staff members that are not assinged to a job.

Basicly i have 2 tables. One contailing all the staff and their information. The second table holds jobs and they information including the assinged staff member to the job.

I would like to generate a list of staff members that have not been assinged to a job yet.

I was thinking about somthing whit a right join maby but i'm not too sure.

Any ideas?

thnx,
Necht

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 05/03/2013 :  04:15:21  Show Profile  Reply with Quote
this would give you an idea

SELECT *
FROM stafftable s
WHERE NOT EXISTS (SELECT 1
                  FROM Jobs
                  WHERE AssignedStaff = s.Staff)


I've assumed table and column names so make sure you use correct names instead

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

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 05/03/2013 :  04:36:03  Show Profile  Reply with Quote
Thnx for the tip, testing it now.

I will let you know how it went.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 05/03/2013 :  04:43:40  Show Profile  Reply with Quote
welcome


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

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 05/03/2013 :  04:45:26  Show Profile  Reply with Quote
Works like a charm, thnx alot! :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 05/03/2013 :  04:48:06  Show Profile  Reply with Quote
you're welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000