1
Coudl請你告訴我wehre我應該把COLLATE DATABASE_DEFAULT
SQL SERVER - 無法解析排序規則衝突的等於操作
獲得創建了以下看法?
我做了搜索,發現我應該把where子句放在每一邊。我嘗試了所有可能性,但仍得到同樣的錯誤,說'無法解決等於操作中「SQL_Latin1_General_CP1_CI_AS」和「Latin1_General_CI_AS」之間的排序規則衝突。
下面是該查詢:
CREATE view [dbo].[NewADUsers] AS SELECT
tbl.objectGUID AS UserGUID
, SUBSTRING(tbl.Email, CHARINDEX('@', tbl.Email)+1,
LEN(tbl.Email)- CHARINDEX('@',tbl.Email)) AS 'DomainName'
, gd.GroupName, dsg.DefaultSubGroup, tbl.sAMAccountName
, tbl.sAMAccountName AS UserName, tbl.Email AS Email
FROM (
SELECT
"SAMAccountName" AS sAMAccountName, "mail" AS Email, "objectGUID" AS objectGUID
FROM OpenQuery(
ADSI,
'SELECT SAMAccountName, mail, objectGUID
FROM ''LDAP://mydomain.com/OU=blah,OU=blah,OU=blah,DC=mydomain,DC=com''
WHERE objectClass=''User'''))
AS tbl
INNER JOIN dbo.GroupsDomains gd ON gd.DomainName = SUBSTRING(tbl.Email, CHARINDEX('@', tbl.Email)+1, LEN(tbl.Email)- CHARINDEX('@',tbl.Email))
LEFT JOIN dbo.DefaultSubGroups dsg ON gd.GroupName = dsg.GroupName
WHERE tbl.objectGUID NOT IN (SELECT UserGUID FROM dbo.Users)
GO