Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Help with SQL query (please)!

$
0
0

Hi Spiceheads, thanks to the lovely folks here I have a working SQL query to export data from two separate tables 'joined' together:

SELECT dbo.OC_USERS.USERID, dbo.PEOPLE.REPORTSTO, dbo.PEOPLE.SUPERVISOR,

FROM dbo.OC_USERS INNER JOIN

dbo.PEOPLE ON dbo.PEOPLE.PEOPLE_ID = dbo.OC_USERS.ASSOCIATEDRECORDID

WHERE (dbo.PEOPLE.STATUS = 'A')

This outputs the AD username (OC_USERS.USERID) alongside various other attributes from PEOPLE which I can then import to AD - this is all working very smoothly. My next challenge is to export the users' dept head (reportsto) and supervisor in the same way. outputting to a csv like this:

userid,reportsto,supervisor

jblogs,msmith,jjones

However, the supervisor and reportsto fields are both guids which match up with peopleID in the OC_Users table. here's some sample data:

OC_USERS

USERID,ASSOCIATEDRECORDID

...


Viewing all articles
Browse latest Browse all 4871


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>