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)
 Generating list of unused staff

Author  Topic 

nechtmarrie
Starting Member

24 Posts

Posted - 2013-05-03 : 04:06:24
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

52326 Posts

Posted - 2013-05-03 : 04:15:21
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

24 Posts

Posted - 2013-05-03 : 04:36:03
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

52326 Posts

Posted - 2013-05-03 : 04:43:40
welcome


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

nechtmarrie
Starting Member

24 Posts

Posted - 2013-05-03 : 04:45:26
Works like a charm, thnx alot! :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-03 : 04:48:06
you're welcome

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

- Advertisement -