duplicates with a date

  • What code do I need to add to have the below code also reflect a date?

    I would like to run this in visual studio 2008 and set up an excel file which I have done already but am having trouble adding a date (daily run) and also getting only fresh data on a daily basis (archiving the data would be preferred).

    select distinct(COMPUTER_NAME),

    COUNT(Computer_Name) AS INSTANCES

    from dbo.table

    GROUP BY COMPUTER_NAME

    HAVING ( COUNT(COMPUTER_NAME) > 1 )

    Thanks,

    JW

  • depends on where your date is, what format, ...

    Do you want to check for duplicates just on that date or check whether the computer name received on that date exists anywhere

    maybe

    select distinct(COMPUTER_NAME),

    COUNT(Computer_Name) AS INSTANCES ,

    convert(varchar(8),getdate(),112) as rundate

    from dbo.table

    where dte >= convert(varchar(8),getdate(),112)

    and dte < convert(varchar(8),getdate()+1,112)

    GROUP BY COMPUTER_NAME

    HAVING ( COUNT(COMPUTER_NAME) > 1 )


    Cursors never.
    DTS - only when needed and never to control.

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

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