I want to replace this Query
DECLARE @tmpUser TABLE( UserId INT, UserType INT )
INSERT INTO @tmpUser
SELECT
u.UserId,
1
FROM
Users u (nolock)
WHERE
u.UPIN = @AttendingDoctorID
IF @@ROWCOUNT = 0
BEGIN
INSERT INTO @tmpUser
SELECT
u.UserId,
1
FROM
Users u (nolock)
WHERE
u.FirstName = @AttendingDoctorFirstName AND
u.LastName = @AttendingDoctorLastName
END
SELECT * FROM @tmpUser
to a single SQL SELECT statement without using @tmpUser or any other temp tables