我正在尝试创建混合Active Directory / SQL Server表查询。以下是我到目前为止的情况:
declare @openQry varchar(500) = '
(SELECT
EC.EmpNo AS [Emp ID]
,EC.FirstName AS [First Name]
,EC.LastName AS [Last Name]
,sAMAccountName AS [AD Username]
,EC.KronosUsername AS [Kronos Username]
FROM OPENQUERY (ADSI,''
SELECT sAMAccountName
FROM ''''LDAP://int.chickasaw.net''''
WHERE objectClass = ''''person'''' ''),
[EnterpriseUtility].[dbo].[Employee_Cache] EC
WHERE sAMAccountName <> EC.KronosUsername
AND EC.EmployeeStatus = ''Active''
)'
exec (@openQry)
这是我在尝试执行查询时遇到的错误。
Ms 4145,Level 15,State 1,Line 11
在预期条件的上下文中指定的非布尔类型的表达式,接近&#39; Emp&#39;。
我将不胜感激。