How to use numeric variable in sql statement inside procedure?
This is my try:
create procedure ##sp_check (
@tolerance numeric
)
AS
Declare @SQL nvarchar(max)
SET @SQL = '
SELECT
*
FROM
a
WHERE
value > @tolerance
'
exec sp_executesql @SQL
go
exec ##sp_check 1
and the ERROR: Must declare the scalar variable "@tolerance".
I think this is because the variable is invisible between ' and '
so I can do it by declaring @tolerance as varchar and in sql statement converting it into numeric but its a bit confusing...