Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CHECK/NOCHECK for Sql Compact Edition

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?
like image 766
Ryan H Avatar asked Oct 16 '09 19:10

Ryan H


People also ask

How do I view a SQL Compact database?

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.

What is with Nocheck in SQL?

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.

How do I access SQL Server Compact Edition?

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.


1 Answers

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.

like image 124
Jason Short Avatar answered Sep 30 '22 08:09

Jason Short