Query

  • Hi All

    Me again... I have a query that extracts data(500 million recs); that is records that has been processed since Desember 2006 up to today;from a table from another server.

    I do I go about extracting yesterdays data, when I'm running it today from all the millions of records?

    Do I use a TOP 10000 clause? but won't this go through all the millions of records and finds the records that matches my criteria and give a resultset?

    Query:

    Declare @BaseDate datetime

    Select @BaseDate  = dateadd(d,-132,getdate())

    truncate table TABLE

    Insert into ANOTHERTABLE

    Select TOP 10000 column names from VIew1 inner join VIew2  ON

    column= column AND INNER JOIN View3 ON column = another column

     

    I desperately need your help pLEASe

    Anchelin

  • Can't you just use a date = getdate() -1 for your where clause?  Maybe I just don't understand the question.

    JG

  • Do you have a datetime column to time stamp the rows at entry so they can be identified or do you have some other way to identify the records as to when they were added?

  • Hi All

    I manage to get this done, but have another problem though. I have the following:

    Declare @FromDate datetime

    Declare @TodayDate datetime

     

    Set @FromDate = (select convert(varchar(8), SNDF.DateTimeSampled -1,112)from tablename)

    Set @TodayDate = (select convert(varchar(8),getdate()-1,112))

    truncate table TABLE

    Insert into ANOTHERTABLE

    Select TOP 10000 column names from VIew1 inner join VIew2  ON

    column= column AND INNER JOIN View3 ON column = another column

     

    How will my code look if I have to get all the dates from the first day the records got processed. It will look like something like this:

    (select convert(varchar(8),getdate()-136,112)) - last year December

    But how will my code look to rerieve all of this data up to today?

    Please, I reaally appreciate all your help

    Anchelin

     

     

     

     

  • We are all asking you if you have a datetime columns in you table.

  • Hi

    Yes, I have a datetime column in my table

    Anchelin

  • Then why you don't use that field to filter records?

  • Can you perhaps show me how to do this? I'm new with T-SQL.

    Please

    Anchelin

Viewing 8 posts - 1 through 7 (of 7 total)

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