How could a stored procdure run in 10 seconds via Management Studio, but take 15 minutes via a TableAdapter for the same inputs? It is repeatable, meaning I have run it at least three times in each environment, and Management Studio is consistently about 100 times faster.
I'm using .net 2.0 and SQL Server 2000
In SQL Server Management, I'm executing it like this:
EXEC [dbo].[uspMovesReportByRouteStep]
@RouteStep = 12000,
@RangeBegin = N'12/28/08',
@RangeEnd = N'1/18/9'
In the TableAdapter, I'm using a StoredProcedure
CommandType
and dbo.uspMovesReportByRouteStep
for the CommandText
. I'm calling the table adapter from an ASP.NET page, although it times out in 30 seconds if I attempt to "Preview Data" locally too.
It's not practical to provide the stored procedure because it's over 100 lines long with dependencies on a number of other UDFs and views on the same and other databases.
All other stored procedures appear to run in about the same time using either method. How is this possible?