Home Forums SQL Server 2008 T-SQL (SS2K8) pulling records from a table between date ranges in another table RE: pulling records from a table between date ranges in another table

  • Sorry about that...let's try this:

    CREATE TABLE #tMILESTONE (

    CustomerID INT NULL,

    LoadDate datetime NULL

    );

    WITH CTE AS

    (

    SELECT 11011 AS CUSTOMERID, GETDATE() AS LoadDate

    UNION ALL

    SELECT 11011, LoadDate + 1

    FROM CTE

    )

    INSERT #tMILESTONE ( CustomerID, LoadDate )

    SELECT TOP 100 CustomerID, convert(varchar, LoadDate, 101) FROM CTE

    I want the recordset to look like (This is just a subset of what you would load above but to give you the idea):

    CustomerID LoadDate Milestone

    11011 2014-03-17 00:00:00.000 30

    11011 2014-03-18 00:00:00.000 30

    11011 2014-03-19 00:00:00.000 30

    11011 2014-04-17 00:00:00.000 60

    11011 2014-04-18 00:00:00.000 60

    11011 2014-04-19 00:00:00.000 60

    11011 2014-05-17 00:00:00.000 90

    11011 2014-05-18 00:00:00.000 90

    11011 2014-05-19 00:00:00.000 90