I think I'm going to be spending a lot of time in this forum. WOW!
Anyway, on to my question/issue ...
I'm using SQL2K5, but I don't think that really matters in the entire scheme of things.
I'm trying to find out how many records were added to one of my tables today. Each record has a column, date_insert, that is populated with the current date and time.
I ran some simple queries this evening to get my record counts. This is what I got back. Obviously, I'm finding the results a little strange, or I wouldn't be posting this.
Code:
/*------------------------
declare @total int,
@before int,
@after int
select @total=count(*) from Equipment
select @before=count(*) from Equipment
where date_insert < '7/3/2007'
select @after=count(*) from Equipment
where date_insert > '7/2/2007'
print 'Total rows: '+cast(@total as varchar)
print 'Rows before: '+cast(@before as varchar)
print 'Rows after: '+cast(@after as varchar)
------------------------*/
Total rows: 34828
Rows before: 34086
Rows after: 2310
Does anyone have an explanation and/or suggestion for how to get the 'correct' answer?
Thanks,
Karen