Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

The selected database contains foreign keys that create a cycle

You may get the following error when creating data scripts with MSSQL 2008: The selected database contains foreign keys that create a cycle. Publishing data only is not supported for databases with cyclical foreign key relationships. This problem is caused by self-referencing tables and it is given even if you don’t export data from one of such tables. Here is simple and very dirty solution.

If some of tables in the list of exported tables has circular references or some of these tables refers to table with circular references then this error occurs. As a very dirty workaround you can temporarily remove circular foreign keys and create them later again. Not very nice solution but works for me.

Comments

asp.net developer said:

Hi,

Thanks for sharing this error detail its great.

# December 31, 2011 2:38 AM