大网数据广告活动
域与目录服务

Creating a Heterogeneous Join between SQL Server & Active Directory

· 52CE 我爱测

All employees at the Fabrikam corporation are reviewed every six months.

All employees at the Fabrikam corporation are reviewed every six months. Review ratings are stored in the Human Resource database in SQL Server. To create a view of this data, Joe Worden, the enterprise administrator, must first create an employee performance review table.

In the SQL Query Analyzer, Joe is going to create a table called EMP_REVIEW that will contain three columns to hold the name of the employee, the date of the review, and the rating that the employee received.

CREATE TABLE EMP_REVIEW
(
userName varChar(40),
reviewDate datetime,
rating decimal 
)

Joe can then insert a few records.

INSERT EMP_REVIEW VALUES('Julie Adam', '2/15/1999', 4 )
INSERT EMP_REVIEW VALUES('Julie Bankert', '7/15/1999', 5 )
INSERT EMP_REVIEW VALUES('Chris Gray', '2/15/1999', 3 )
INSERT EMP_REVIEW VALUES('Chris Gray', '7/15/1999', 4 )

Now Joe can join the Active Directory user objects to the SQL Server table.

In this example, the SELECT statement contains the list of data that will be obtained from the directory service and SQL Server. The FROM statement contains the name of the linked directory server where this information will be obtained from, in this case, viewADUsers. The WHERE statement provides the search conditions. In this example, it is searching by the name in the directory service, which is set to the SQL userName entered in the previous task.

SELECT ADsPath, userName, title, ReviewDate, Rating 
FROM EMP_REVIEW, viewADUsers
WHERE userName = Name

The previous command gets the result from both SQL Server and Active Directory. AdsPath and title are from Active Directory, whereas userName, ReviewDate, and Rating are from the SQL table. He can even create another view for this join.

CREATE VIEW reviewReport
AS
SELECT ADsPath, userName, title, ReviewDate, Rating 
FROM EMP_REVIEW, viewADUsers
WHERE userName = Name
GO
SELECT * FROM reviewReport

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。