I Have a table SalesHistory in one of my development server which shows 96 rows when viewed via EM and sysindexes. but actually there are no rows in that. There is no open transactions, I ran DBCC UPDATEUSAGE(0), UPDATE STATISTICS SalesHistory, restarted the server only to see the same result. what could be the problem??? Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
What is the service pack on SQL server? Run select count(*) from QA to see the results. Satya SKJ Microsoft SQL Server MVP Contributing Editor & Forums Moderator http://www.SQL-Server-Performance.Com This posting is provided AS IS with no rights for the sake of knowledge sharing.
Select count(*) shows me 0 rows. Microsoft SQL Server 2000 - 8.00.818 (Intel X86) May 31 2003 16:08:15 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4) Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
Additional information... two of my other development servers are of same configuration and service level. but i didnt face problems with those... Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
Have you tried prefixing the table with owner name? It could be just that there are two tables with the same name, but different owners. Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
I checked. There is no other owner other than dbo on that machine. that was a nice try. i didnt think that way initially... Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
quote:Originally posted by ramkumar.mu I checked. There is no other owner other than dbo on that machine. that was a nice try. i didnt think that way initially... What you see when you open the table in EM? Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
When i right click on table and if i see the properties, there it shows "owner dbo Rows 96" . but when i went through the option "open Table->Return all rows", i dont see any value. quote:Originally posted by Roji. P. Thomas quote:Originally posted by ramkumar.mu I checked. There is no other owner other than dbo on that machine. that was a nice try. i didnt think that way initially... What you see when you open the table in EM? Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
I cant understand that. can you please post the full query? quote:Originally posted by dineshasanka did you try with select(filedName) ---------------------------------------- Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
As this is a development server, do you think really it is a problem? Check whether similar behaviour occurring on Production servers. Satya SKJ Microsoft SQL Server MVP Contributing Editor & Forums Moderator http://www.SQL-Server-Performance.Com This posting is provided AS IS with no rights for the sake of knowledge sharing.
quote:Originally posted by ramkumar.mu When i right click on table and if i see the properties, there it shows "owner dbo Rows 96" . but when i went through the option "open Table->Return all rows", i dont see any value. The Table properties window in EM calls the procedure sp_MStablespace, which in turn refer the rowcnt column in sysindexes to get the row count. So the original problem here is that the sysindexes is not getting properly updated. Try updating statistics again with UPDATE STATISTICS [TableName] WITH FULLSCAN Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
Or even run DBCC UPDATEUSAGE(usertable) Oops, a typo [:I] Satya SKJ Microsoft SQL Server MVP Contributing Editor & Forums Moderator http://www.SQL-Server-Performance.Com This posting is provided AS IS with no rights for the sake of knowledge sharing.
quote:Originally posted by satya Or even run DBCC UPDATEUSAGE(sysindexes) Sysindexes? Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
I tried your query. it didnt work... [<img src='/community/emoticons/emotion-6.gif' alt='' />]<br /><br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Roji. P. Thomas</i><br /><br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by ramkumar.mu</i><br /><br />When i right click on table and if i see the properties, there it shows "owner dbo Rows 96" . but when i went through the option "open Table->Return all rows", i dont see any value.<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />The Table properties window in EM calls the procedure sp_MStablespace, which in turn refer the rowcnt column in sysindexes to get the row count. So the original problem here is that the sysindexes is not getting properly updated.<br /><br />Try updating statistics again with <br /><br />UPDATE STATISTICS [TableName] WITH FULLSCAN<br /><br /><br />Roji. P. Thomas<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://toponewithties.blogspot.com>http://toponewithties.blogspot.com</a><br /><br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />Thanks,<br />Ram<br /><br />"It is easy to write code for a spec and walk in water, provided, both are freezed..."
Just in case if i get the same problem in any other server... quote:Originally posted by satya As this is a development server, do you think really it is a problem? Check whether similar behaviour occurring on Production servers. Satya SKJ Microsoft SQL Server MVP Contributing Editor & Forums Moderator http://www.SQL-Server-Performance.Com This posting is provided AS IS with no rights for the sake of knowledge sharing. Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by ramkumar.mu</i><br /><br />I tried your query. it didnt work... [<img src='/community/emoticons/emotion-6.gif' alt='' />]<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />OK. Try<br /><br />EXEC sp_statistics [@table_name =] 'SalesHistory', @accuracy = 'E'<br /><br /><br /><br />Roji. P. Thomas<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://toponewithties.blogspot.com>http://toponewithties.blogspot.com</a><br />
I tried DBCC UPDATEUSAGE(0) and UPDATEUSAGE(TableName). it didnt work... quote:Originally posted by satya Or even run DBCC UPDATEUSAGE(usertable) Oops, a typo [:I] Satya SKJ Microsoft SQL Server MVP Contributing Editor & Forums Moderator http://www.SQL-Server-Performance.Com This posting is provided AS IS with no rights for the sake of knowledge sharing. Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
If the last method I mentioned also failed to correct the issue, try the following. DBCC UPDATEUSAGE (0, 'SalesHistory') WITH COUNT_ROWS Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
DDS_Staging_1dboSalesHistoryNULLNULLNULL0NULLNULLNULL9693NULL<br />96 is the cardinality and 93 is pages<br /><br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Roji. P. Thomas</i><br /><br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by ramkumar.mu</i><br /><br />I tried your query. it didnt work... [<img src='/community/emoticons/emotion-6.gif' alt='' />]<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />OK. Try<br /><br />EXEC sp_statistics [@table_name =] 'SalesHistory', @accuracy = 'E'<br /><br /><br /><br />Roji. P. Thomas<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://toponewithties.blogspot.com>http://toponewithties.blogspot.com</a><br /><br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />Thanks,<br />Ram<br /><br />"It is easy to write code for a spec and walk in water, provided, both are freezed..."
Wow!!! that worked. It showed a message like "rowcount changed from (96) to (0). " can you please explain what we did? quote:Originally posted by Roji. P. Thomas If the last method I mentioned also failed to correct the issue, try the following. DBCC UPDATEUSAGE (0, 'SalesHistory') WITH COUNT_ROWS Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
Do you have a clustered index on the table? Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
No! i dont have any index on that table. Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
quote:Originally posted by ramkumar.mu Wow!!! that worked. It showed a message like "rowcount changed from (96) to (0). " can you please explain what we did? Well, we just asked SQL server to go count each rows and update the entry in sysindexes. Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
OK.. then why didnt it work with DBCC UPDATEUSAGE(0) DBCC UPDATEUSAGE('SalesHistory') Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."
quote:Originally posted by ramkumar.mu OK.. then why didnt it work with DBCC UPDATEUSAGE(0) DBCC UPDATEUSAGE('SalesHistory') I dont know the reason. UPDATEUSAGE itself is supposed to correct the inaccuracies in sysindexes. But, with the option WITH COUNT_ROWS , we are explicitly asking for updating the rowcnt (and rows) column with teh current count from teh table. But I can tell you that, your chances of facing this problem is far less with a clustered index instead of a heap. Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
Thanks a lot Roji for all your help. Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."