I am running the following script daily:
exec sp_updatestats
go
exec sp_createstats 'indexonly'
go
The sp_createstats raises an error:
Msg 1927, Level 16, State 2, Line 1
There are already statistics on table 'XXX$Detail Line' named 'B-Account'.
If I set the property MaintainSQLIndex to NO on the specific key. The script runs fine.
But of course, this is not the solution.
0
Answers
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Maybe clean up previously created Auto Stats using this little script:
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Thanks for the fast reply
Unfortunately the script doesn't resolve the error.
The following keys exist on Table Detail Line:
Enabled Key SumIndexFields
Yes Transaction No.
Yes Account Type,Serial No. (Entry),Status,Date Amount,Amount (Entry)
Yes Account Type,Account No.,Bank,Transaction Mode,Currency Code,Date
Yes Our Bank,Status,Connect Batches,Connect Lines,Date Amount,Amount (Entry)
Yes Account Type,Serial No. (Entry),Status,Transaction No.,Subcontracting,B-Account Amount,Amount (Entry)
I did the following and found weird results:
1. I removed field "B-Account" from the key > sp_createstats works fine.
2. I added field "B-Account" to the key again > sp_createstats does NOT work.
3. I renamed field "B-Account" to "BAccount" > sp_createstats works fine! Strange.
4. I renamed field "BAccount" back to "B-Account" again > sp_createstats works fine! Very strange!
Anyway. It works now.
1) I created this table:
2) I created these Keys/Indexes:
3) I run sp_createstats 'indexoly':
No problemo ... :-k
What collation do you use? Which SQL build? NAV build?
Does anything change if you delete al stats created by sp_createstats using that script?:
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Collation: Latin1_General_CI_AS
SQL Server version: 10.50.2550.0
NAV build: 32480
I also can not reproduce the error anymore.
Seems renaming the field solved the problem...
I don't know what went wrong and since when.
For me the issue is closed.
But if you find the cause, I'd like to know
If that happens I suggest to erase the users stats using that script (if possible by adding a filter on the relevant tablename): Then I try to recreate the stats from the scratch, using sp_createstats 'indexonly' ...
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool