Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cause of "The referenced entity ‘tablename’ was modified during DDL execution" (error 2021)?

480 views
Skip to first unread message

John Hardin

unread,
Oct 25, 2017, 2:50:12 PM10/25/17
to
Folks:

Our application has a helper SP that creates lightly-customized work SPs
from a generic SP template. It customizes the template SP's code into a
nvarchar() and then uses sp_executesql to create the custom work SP from
that so it can be executed.

This has been working reliably for *years*. This week we've started
getting scattered reports of that helper SP dying with this error when it
tries to run the customized SQL to create the work SP:

Error executing command "create_work_stored_proc_$sp": The referenced
entity 'some_table' was modified during DDL execution. Please retry the
operation.

...where "some_table" is one of the tables referenced by the template SP
code.

Searching the web for that error either by the text or by the error number
(error 2021) only finds notes that this error does exist in (some) lists
of SQL Server error messages. I can't find any explanation of the actual
cause anywhere.

I would be shocked if data changes to the table in question (DML
operations) would cause this error. I would be less surprised if it was
colliding with another DDL operation (like, most plausibly, a statistics
update or online index rebuild on that table). It's possible that data
maintenance and process execution schedules have accidentally overlapped
here and there, and this is the result.

Can anyone provide any concrete information as to what actually causes
this error to occur?

Thanks!

--
John Hardin KA7OHZ
Senior Retail Applications Developer
Aptôs
web: http://www.aptos.com
email: <jha...@aptos.com>
0 new messages