Hi
I have a query which takes 1 sec to return results when the WHERE clause is as follows
WHERE (FT.FT_BAD_TRAN=0)
AND (FB.FB_DATE BETWEEN '20080602' AND '20080608')
However, the query is to become a stored procedure with input parameters. When I declare & set variables for the date range the query just executes indefinitely & never returns rows:
DECLARE @FromDate smalldatetime
DECLARE @ToDate smalldatetime
SET @FromDate = '20080602'
SET @ToDate = '20080608'
WHERE (FT.FT_BAD_TRAN=0)
AND (FB.FB_DATE BETWEEN @FromDate AND @ToDate)
A debug message shows the date variables are set correctly
Any ideas what could be going on? The database is an ERP type product with large amounts of data. There is a date index on the FB table which I'm guessing is not being used when parametes are in the WHERE clause but I have no idea why this would be.
Thanks!
I have a query which takes 1 sec to return results when the WHERE clause is as follows
WHERE (FT.FT_BAD_TRAN=0)
AND (FB.FB_DATE BETWEEN '20080602' AND '20080608')
However, the query is to become a stored procedure with input parameters. When I declare & set variables for the date range the query just executes indefinitely & never returns rows:
DECLARE @FromDate smalldatetime
DECLARE @ToDate smalldatetime
SET @FromDate = '20080602'
SET @ToDate = '20080608'
WHERE (FT.FT_BAD_TRAN=0)
AND (FB.FB_DATE BETWEEN @FromDate AND @ToDate)
A debug message shows the date variables are set correctly
Any ideas what could be going on? The database is an ERP type product with large amounts of data. There is a date index on the FB table which I'm guessing is not being used when parametes are in the WHERE clause but I have no idea why this would be.
Thanks!