Aug 04 2022 03:54 AM
Hi there,
I try to delete a foreign key with
"
ALTER TABLE [dbo].[Projektplanung] DROP CONSTRAINT [Projektplanung$tblLookupCountriesProjektplanung]
GO
"
But I have to cancel it and get Err 3737 afterwoods as it doesn´t finish. This worked for months now as this is built into a script where I delete the constraint and build it again after importing data into the table.
As this command works with 50 more tables and I get this error on 3 tables since today I´m very confused.
Aug 04 2022 04:33 AM
Aug 04 2022 05:37 AM
Solution@Martin_Sachers , next time please post the complete error message, not only the number.
select *
from sys.messages
where message_id = 3727
> Could not drop constraint. See previous errors.
And what was the previous error?
Olaf
Aug 04 2022 06:50 AM
@olafhelper There were no previous errors. It just did nothing visibly.
The problem is solved: There are 4 foreign keys which connect to the table. I tried the whole story an hour later and it worked again. Conclusio: The table was locked. The problem is that it didn´t show at all.
BR
Martin
Aug 05 2022 09:07 PM
For the sake of the next time.
> There were no previous errors.
You can get the previous error and all the information which come in the errors from the SQL Server error log file, as explain the this doc.
> Conclusio: The table was locked. The problem is that it didn´t show at all.
Next time you can check locks using sp_lock or sys.dm_tran_locks.
I am not sure that your conclusion are correct without more info
> The problem is solved
Glad to hear :) have a great day
Aug 04 2022 05:37 AM
Solution@Martin_Sachers , next time please post the complete error message, not only the number.
select *
from sys.messages
where message_id = 3727
> Could not drop constraint. See previous errors.
And what was the previous error?
Olaf