1

After syncdb creates the tables I get an error when enabling the constraints:

Installing custom SQL ...
Installing indexes ...
DatabaseError: (-2147352567, 'Exception occurred.', (0, u'Microsoft SQL Server N
ative Client 10.0', u'Query timeout expired', None, 0, -2147217871), None)
Command:
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Parameters:
[]

But when running the below command manually against the same database after the tables have been created, it runs without errors:

EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

The database contains hundreds of tables that are not generated by Django itself. Running syncdb against an empty MSSQL database does not produce this error. Could this be a timeout caused by too many tables in the database? If so, would I resolve it? I'm using the django-mssql drivers.

dan-klasson
  • 13,734
  • 14
  • 63
  • 101
  • The "WITH CHECK" can be a slow operation for large databases. Part of syncdb disables foreign keys and later re-enables them. After they are re-enabled, the tables need to be checked to make sure bad data didn't get a chance to slip in without being noticed. How long does the command take when run manually? You'll most likely need to increase the COMMAND_TIMEOUT as answered by @krescruz – Manfre Jan 06 '14 at 15:34

1 Answers1

2

change parameter COMMAND_TIMEOUT in config database Setting.py Example:

'COMMAND_TIMEOUT': Numberseconds
krescruz
  • 418
  • 4
  • 7