Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

select * from sysobject crashes

Posted on 2011-09-09
12
Medium Priority
?
915 Views
Last Modified: 2012-05-12
when i do the first query from below, i get
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.

the second & third one are fine.. why would the select be a problem? i was watching it in profiler, but could not find what is offending..
exec sp_msforeachdb 'use [?] if exists (select 1 from [?]..sysobjects where name = ''licuser'')  select count(*) from licuser'
exec sp_msforeachdb 'use [?] if exists (select 1 from [?]..sysobjects where name = ''PMTellStat'')  select count(*) from PMTellStat'

exec sp_msforeachdb 'use [?] if exists (select 1 from [?]..sysobjects where name = ''abcd123THISDOESNOTEXIST'')  select count(*) from abcd123THISDOESNOTEXIST'

Open in new window

0
Comment
Question by:25112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 5

Author Comment

by:25112
ID: 36509831
i found the database it is failing..

select * from licuser gives the above errors, too.. so it is not sysobjects.. i went to ssms adn drilled through the table.. i am getting the error on 'statistics'..

what corrupts a statistic? any way to fix this? can we check how many more tables are like this?
0
 
LVL 5

Author Comment

by:25112
ID: 36509868
i ran checkdb, and it comes back as

CHECKDB found 0 allocation errors and 0 consistency errors in database
0
 
LVL 21

Accepted Solution

by:
JestersGrind earned 1000 total points
ID: 36509951
If it is corrupt statistics, the only way to fix it that I know of is to rebuild the indexes.  As far as I know, there is no way to detect corrupt statistics.  Other than when you receive the error.

Greg

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 5

Author Comment

by:25112
ID: 36509953
this is in sql r2.
0
 
LVL 16

Assisted Solution

by:EvilPostIt
EvilPostIt earned 800 total points
ID: 36510302
As per jestersgrinds comment rebuild all of the tables indexes using

ALTER INDEX ALL ON [TableName] REBUILD

Open in new window

0
 
LVL 5

Author Comment

by:25112
ID: 36511154
just before i saw your post, the had put sp1, and since then i do not get that error anymore. does a new service pack rebuild indexes?
0
 
LVL 16

Expert Comment

by:EvilPostIt
ID: 36511305
No i dont believe so. Otherwise if you have large databases it could take a very long time to upgrade...
0
 
LVL 5

Author Comment

by:25112
ID: 36517477
i had a ticket with MS for something else.. and this was explained to me this way:
SP1 - because it implements many system views/tables as part of its installation, it goes through and validates/refreshes all the statistics, because all the objects have to have reference to the new implementations of SP1...

in terms of checking in the future for statistic corruption, would you think the following idea is efficient:
sp_msforeachtable 'select top 1 * from ?'
if there is any problem with the table statistics, it will err out?

If I should have this issue later anytime, i guess the index rebuild will help out big time.. i could just run it on the offending tables? would you say so?
0
 
LVL 16

Assisted Solution

by:EvilPostIt
EvilPostIt earned 800 total points
ID: 36521562
Hmmm, thats interesting...

You are better off just rebuilding the table in future as that will rebuild the stats too.
0
 
LVL 5

Author Comment

by:25112
ID: 36523676
OK- what is the syntax to 'rebuild table'
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 200 total points
ID: 36524445
>>OK- what is the syntax to 'rebuild table' <<
You may want to re-read the thread.  Specifically this comment:
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_27299647.html#a36510302
0
 
LVL 5

Author Comment

by:25112
ID: 36537074
yes, helped.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question