I have an old database in Sql Server 2000 which I still have to maintain. I have these two queries:
SELECT col1,
COUNT(*)
FROM someTable
WHERE YEAR = 2012
AND c_id = 1
AND p_id = 4
GROUP BY
col1
SELECT COUNT(*)
FROM someTable
WHERE YEAR = 2012
AND c_id = 1
AND p_id = 4
AND col1 = '11111'
When I find this same value '11111' in first query it shows 3 more rows then in second query. How is this possible? There is only problem for this value of kol1. It also produces different sum.
Is there any chance that database corruption or something like that could produce this problem?
I tried this update:
update sometable
set col1=ltrim(rtrim(col1))
where c_id=1
and p_id=4
and year=2012
It has thrown this error:
Could not find the index entry for RID '16140001100032303132811300400' in index page (1:76450), index ID 2, database 'xxx'.
Thanks everybody for trying to help me. After unsuccessfully trying to update row I did index rebuild, updated col1 with ltrim(rtrim()) and now it produces correct results.