0

I'm trying to change a column data type from datetime2 to datetimeoffset. I have db owner permissions.

Whenever I run the query:

alter table dbo.<my-table>
alter column [TimeStamp] datetimeoffset

I get the following error message:

The statistics 'Stat_a41cbd7f968a4cba86199c960f6f7c3a' is dependent on column 'TimeStamp'.

ALTER TABLE ALTER COLUMN TimeStamp failed because one or more objects access this column.

However, it looks like this statistic 'Stat_a41cbd7f968a4cba86199c960f6f7c3a' is not present in my sys.stats table, which is very odd.

Is there any other location it might be defined?

Edit: There isn't a single entry in sys.stats named 'Stat_a41cbd7f968a4cba86199c960f6f7c3a'. In addition, I have never defined any custom statistics other than the automatic ones.

2
1

After reaching out to Azure support, I have managed to solve the issue.

Part of the support engineer's answer included the following:

I've reviewed internal telemetry and can confirm that the statistic listed in the error does not exist. This is likely a compute-node-level statistic that wasn't cleaned up properly.

I was able to confirm and fix this issue by doing the following steps:

  1. Run a CTAS to create a copy of the table
  2. Rename the previous table to something different (eg: ) and the new one to the original table name
  3. DROP the old table

After that, the ALTER TABLE statement worked as expected.

1
  • It seems that CTAS is Microsoft's answer to every Synapse issue. It's not a fix. It's a workaround. – Tannis00 Apr 13 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.