November 15, 2010 at 12:52 pm
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
November 16, 2010 at 9:31 am
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