I am using SQL Server 2012, and PHP 7.4. I have a stored procedure called temp
that returns a number rounded to 2 decimal places.
CREATE PROCEDURE temp AS
SELECT
ROUND(t.Real_Weight_Per_Part, 2) as realWeightPerPart
FROM t
EXEC temp
The result:
Which is what I expect. However, when I call this stored procedure from PHP like so:
$sql = "EXEC temp";
$stmt = $conn->prepare($sql);
$stmt->execute();
$data = $stmt->fetchAll(\PDO::FETCH_ASSOC);
I get the following response in $data
:
[
{"realWeightPerPart": "11.359999999999999"},
{"realWeightPerPart": "60.5"},
{"realWeightPerPart": "11.359999999999999"},
...
]
Why is it that when I am in the SQL Server window and I execute the stored procedure, I get the rounded results, but when I execute it from PHP I get the unrounded results?