--Declaring the required variables DECLARE @fromdate DATETIME DECLARE @todate DATETIME SET @fromdate = '2010-01-01' SET @todate = '2010-01-10' --Query to fetch all the dates between two given date ;WITH tmpinfo(tmpdt) AS (SELECT @fromdate UNION ALL SELECT tmpdt + 1 FROM tmpinfo WHERE tmpdt < @todate) SELECT * FROM tmpinfo OPTION (MAXRECURSION 0);
Saturday, August 6, 2011
Writing a recursive query to find out all dates between two given date
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment