Fill Dates in Dimentions

  • Guys, another question that must be easy fr you, though challenging for me...

     

    I have a table called dim_time which contains only dates in the form '1900-01-01 00:00:00.000'. Now i must fill dates that exist in 2 other tables one table called futureexams and contains the exam_datetime column (datetime), and the other table called userexams contains the exam_date(datetime) column. I want to check the dim_time table, and if any of the datetime values from the other two tables do not exist, then enter them into the table dim_time. (note i do not care if the intermediate dates do not exist in dim_time). If i find a date that is either in  futureexams or userexams and does not exist in the table dim_time, then i want to insert it.  Do i need to join the two tables userexams and futureexams, and then check if the dates exist in dim_time?

    I would be grateful if you could provide me with some assistance, and / or relative sql code..

    Thank you,

    Dionisis

     

     


    "If you want to get to the top, prepare to kiss alot of bottom"

  • Hope this solve your purpose,

    insert into dim_time

    (

    Select outdate

    from

     (select exam_datetime outdate from futureexams

     union

     Select exam_date outdate from userexams ) A

    where A.outdate not in (Select DimTime.TheDateFiled dim_time)

    )

  • YES IT DID HELP MATE, THANK YOU


    "If you want to get to the top, prepare to kiss alot of bottom"

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply