Reputation: 10134
i have a proc that loads a users table and in doing so makes an association between users and their managers. i have the simple select below to figure out maangerId for each user record. i see there is a manager that should be assigned to a user but the user gets a blank and the assignment of managerId is missing.
DECLARE @managerId INT
SET @managerId = NULL
IF @CorpManagerDN IS NOT NULL
BEGIN
IF EXISTS (SELECT 69 FROM Employees WITH(NOLOCK) WHERE CorpManagerDN = @CorpManagerDN)
BEGIN
SELECT @managerId = EmployeeId FROM Employees WHERE CorpDN = @CorpManagerDN
END
END
the userId is a self incrmenting field so that works out well, and the managerId field is populated with the logic above. i notice sometimes i get blank managerId values when i see CorpManagerDN values like
CN=Tsahalis\, Peter NBKPVUD,OU=Pre-BAND,OU=Accounts,OU=BAND,DC=corp,DC=bankofamerica,DC=com
and i see CORPDN value of the manager like
CN=Tsahalis\, Peter NBKPVUD,OU=Pre-BAND,OU=Accounts,OU=BAND,DC=corp,DC=bankofamerica,DC=com
but the sql evaluation doesn't match them?
Upvotes: 0
Views: 263
Reputation: 52645
They seem equal to me
select
case when
'CN=Tsahalis\, Peter NBKPVUD,OU=Pre-BAND,OU=Accounts,OU=BAND,DC=corp,DC=bankofamerica,DC=com'
= 'CN=Tsahalis\, Peter NBKPVUD,OU=Pre-BAND,OU=Accounts,OU=BAND,DC=corp,DC=bankofamerica,DC=com'
THEN 1
else 0
END
Upvotes: 1