In my PHP script, I made a connection with the MS SQL database server with the following code,
$connectionInfo = array( "Database"=>$database,"UID"=>$uid, "PWD"=>$pwd);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
Mistakenly I did forget to specify the "CharacterSet"=>"UTF-8"
in the $connectionInfo
. Due to this reason, some Spanish and other characters have been encoded wrong. For example, "álgebra" is stored as "álgebra". Now that I have set the proper character set during the connection to the database, new data is stored correctly. But how can I restore the original strings that had been encoded wrongly and stored already?