I am attempting to wipe and repopulate test data on SQL CE. I am getting an error due to FK constraints existing. Typically in Sql2005 I would
ALTER TABLE [tablename] CHECK/NOCHECK CONSTRAINT ALL
to enable/disable all constraints. From what I could find in my searching, it seems that this might not be supported in CE. Is that true? If so, is there an alternative?
Click View >>Toolbars >>SQL Server Compact Edition Editor as shown. SQL Server Compact Toolbox on Codeplex - It is a Visual Studio add-in and standalone app , for managing all aspects of your SQL Server Compact database files.
WITH NOCHECK does so without checking existing data. So the confusing syntax WITH NOCHECK CHECK CONSTRAINT enables a constraint without checking existing data. From the manual: Specifies whether the data in the table is or is not validated against a newly added or re-enabled FOREIGN KEY or CHECK constraint.
In Object Explorer, click Connect, and then choose SQL Server Compact. 2.In the Connect to Server dialog box, select from the Database file drop-down list. 3.In the Create New SQL Server Compact Database dialog box, type a file path and file name for the new database file.
NOCHECK is not supported on SQL CE 3.1/3.5
ALTER TABLE SQL CE
The usual method to accomplish this is to drop the constraint, do your operations and then add it back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With