I have a weird scenario where when I execute a stored the query takes 30 mins +. If I take the body of the stored proc and convert the parameters to variables it takes 1:30.
I'm running this in SSMS.
The stored proc does a select with a few joins. Something like this
CREATE OR ALTER PROCEDURE [report].[MyReport]
@DataPackageId INT,
@DefaultAsOf DATETIME2(7),
@DefaultDealAsOf DATETIME2(7)
AS
SELECT
*
FROM
reporthelper.FuncA(@DataPackageId,@DefaultAsOf, @DefaultDealAsOf) FuncA
LEFT JOIN reporthelper.FuncB(@DataPackageId,@DefaultAsOf, @DefaultDealAsOf) FuncB
ON FuncA.Field1 = FuncB.Field2
AND FuncA.Field1 = FuncB.Field2
--More Joins
GO
Why would the executing times vary that much between the 2 scenarios if its essentially the same SQL executing?