I have a query that I captured through an extended events session with a float datatype that looks like :
@variable = 120700.8000000000000000000000000000000000000000000000
If I try to run the same query in SSMS, I get the error: The number '120700.8000000000000000000000000000000000000000000000' is out of the range for numeric representation (maximum precision 38).
Same as if you were to run
DECLARE @variable float = 120700.8000000000000000000000000000000000000000000000
The query succeeded when the trace was running. The Event is rpc_completed and it has a duration, cpu, rowcount, etc...
Not sure if this is relevant, but the query in question is an exec sp_executeSQL. The full query as captured by the trace looks like:
exec sp_executeSQL N'SELECT
col1,
col2
FROM table
WHERE col3 > @variable', N'@variable float',
@variable = 120700.8000000000000000000000000000000000000000000000
So my question is, why is the code in the trace able to execute without error, but when I copy/paste that same code to SSMS it throws an error. If I take that same code and trim off a bunch of those zeros it works.
I am running on SQL Azure DB. I have reproduced on compatibility SQL2016, SQL2019, and on Prem SQL2019.