question

Pike avatar image
Pike asked

Unable to identify missing record using view

SQL that works as it should other than I can't limit to active students

SELECT stud.other_id
FROM   student stud
       LEFT JOIN (SELECT *
                  FROM   Openquery (adsi, 'SELECT sAMAccountName
  FROM ''LDAP://.....''
WHERE objectClass = ''User''
'))AD
              ON stud.other_id = AD.samaccountname
                 AND ad.samaccountname IS NULL 

View used to get active students

CREATE VIEW [dbo].[VW_Enrolled_Students] AS SELECT dbo.student.student_id, dbo.student.name_id, dbo.student_ew.entity_id, dbo.student_ew.ew_date, dbo.student.other_id, dbo.student.student_in_stn, dbo.student.grad_yr FROM dbo.student INNER JOIN dbo.student_ew ON dbo.student.student_id = dbo.student_ew.student_id WHERE (dbo.student_ew.withdrawal_date IS NULL) GO

code used to identify missing AD accounts for active students

SELECT Stud.other_id FROM [vw_enrolled_students] Stud left JOIN (SELECT * FROM Openquery (adsi, 'SELECT sAMAccountName FROM ''LDAP://......'' WHERE objectClass = ''User'' ')) AD ON Stud.other_id = ad.samaccountname AND ad.samaccountname IS NULL

tsqltemporary-tableunique
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.