The reason is because the line while ($row = ....) will get reset as a precursor to exiting the loop.
If you're expecting only one row returned, you can remove the while loop.
So you can do something like
$row = sqlsrv_fetch_array ( $result2, SQLSRV_FETCH_ASSOC)
while ($row = sqlsrv_fetch_array ( $result2, SQLSRV_FETCH_ASSOC))
This will give you $row for use later as you seem to need. I would recommend though, to use something other than $row, something more relevant to the data it's holding, such $user_data if it's holding user information. This will make code easier to read and understand later, and you won't into the habit of using arbitrary names like $row, which you might overwrite later on in the page.