I'm trying to update an table (se code below). Where, when a match I want to extract the UserID, if there's no match I want to it to be given the value 6000. However, the script doesn't do what I would expect it to do. If U.UserID doesn't exist it doesn't write any value (6000), not if it's null. How can I go around the problem?
/* Ensure Person (UserID)*/
UPDATE #List
SET #List.UserID = ISNULL(U.UserID, '6000')
FROM #List
INNER JOIN table1 t1 ON #List.ID = t1.ID
INNER JOIN User U ON U.FirstName + ' ' + U.Surname = t1.PersonFullname
#Listis not joined to any tables inFROMpart, that is why you are getting bad results. What is#iListand how it could be joined?