constraints

Temporarily disable all foreign key constraints

房东的猫 提交于 2019-12-17 10:16:10
问题 I am running an SSIS package which will replace data for a few tables from FlatFiles to existing tables in a database. My package will truncate the tables and then insert the new data. When I run my SSIS package, I get an exception because of the foreign keys. Can I disable the constraints, run my import, then re-enable them? 回答1: To disable foreign key constraints: DECLARE @sql NVARCHAR(MAX) = N''; ;WITH x AS ( SELECT DISTINCT obj = QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' +

SQL Server 2008- Get table constraints

淺唱寂寞╮ 提交于 2019-12-17 07:16:12
问题 Could you help me frame a query that retrieves the constraints in all the tables, the count of constraints in each table, and also display NULL for tables that do NOT have any constraints. Thx in advance! This is what I have so far: Select SysObjects.[Name] As [Constraint Name] , Tab.[Name] as [Table Name], Col.[Name] As [Column Name] From SysObjects Inner Join (Select [Name],[ID] From SysObjects) As Tab On Tab.[ID] = Sysobjects.[Parent_Obj] Inner Join sysconstraints On sysconstraints.Constid

SQL Server 2008- Get table constraints

我与影子孤独终老i 提交于 2019-12-17 07:16:02
问题 Could you help me frame a query that retrieves the constraints in all the tables, the count of constraints in each table, and also display NULL for tables that do NOT have any constraints. Thx in advance! This is what I have so far: Select SysObjects.[Name] As [Constraint Name] , Tab.[Name] as [Table Name], Col.[Name] As [Column Name] From SysObjects Inner Join (Select [Name],[ID] From SysObjects) As Tab On Tab.[ID] = Sysobjects.[Parent_Obj] Inner Join sysconstraints On sysconstraints.Constid

How can I use interface as a C# generic type constraint?

一曲冷凌霜 提交于 2019-12-17 05:39:09
问题 Is there a way to get the following function declaration? public bool Foo<T>() where T : interface; ie. where T is an interface type (similar to where T : class , and struct ). Currently I've settled for: public bool Foo<T>() where T : IBase; Where IBase is defined as an empty interface that is inherited by all my custom interfaces... Not ideal, but it should work... Why can't you define that a generic type must be an interface? For what it's worth, I want this because Foo is doing reflection

UIScrollView and Constraints

ぐ巨炮叔叔 提交于 2019-12-17 05:13:28
问题 I'm trying to place a UIImageView at the top of a UIScrollView and when I constrain the UIScrollView to the sides of the View Controller and constrain the UIImageView to the top and make the width of the UIImageView equal to the UIScrollView it makes the UIImageView way wider than the UIScrollView, and much taller than expected. Any idea what I'm doing wrong? Storyboard: Preview: 回答1: Check that following constraints are added to your view: Go to Storyboard -> Select your view Now at right

How to Create layout constraints programmatically

99封情书 提交于 2019-12-17 04:22:53
问题 I am displaying a view in the bottom of the universal application and adding this view dynamically in my view. I want to show this view in bottom every time like iAd. in both orientation. How can I add constraints for this. Please suggest. Thanks 回答1: To fix a view to the bottom of the screen you need following constraints to set. Leading Constraint with respect of Parent View for - X Trailing Constraint with respect of Parent View for - Width Bottom Constraint with respect of Parent View for

How to Create layout constraints programmatically

十年热恋 提交于 2019-12-17 04:22:02
问题 I am displaying a view in the bottom of the universal application and adding this view dynamically in my view. I want to show this view in bottom every time like iAd. in both orientation. How can I add constraints for this. Please suggest. Thanks 回答1: To fix a view to the bottom of the screen you need following constraints to set. Leading Constraint with respect of Parent View for - X Trailing Constraint with respect of Parent View for - Width Bottom Constraint with respect of Parent View for

How do I add a custom CHECK constraint on a MySQL table?

心已入冬 提交于 2019-12-17 03:03:45
问题 I am having trouble with this table CREATE TABLE `Participants` ( `meetid` int(11) NOT NULL, `pid` varchar(15) NOT NULL, `status` char(1) DEFAULT NULL, PRIMARY KEY (`meetid`,`pid`), CONSTRAINT `participants_ibfk_1` FOREIGN KEY (`meetid`) REFERENCES `Meetings` (`meetid`) ON DELETE CASCADE CONSTRAINT `participants_ibfk_2` CHECK (status IN ('a','d','u')) CONSTRAINT `participants_ibfk_3` CHECK (pid IN (SELECT name FROM Rooms) OR pid IN (SELECT userid FROM People)) ); I want to have a foreign key

How do I add a custom CHECK constraint on a MySQL table?

蹲街弑〆低调 提交于 2019-12-17 03:03:20
问题 I am having trouble with this table CREATE TABLE `Participants` ( `meetid` int(11) NOT NULL, `pid` varchar(15) NOT NULL, `status` char(1) DEFAULT NULL, PRIMARY KEY (`meetid`,`pid`), CONSTRAINT `participants_ibfk_1` FOREIGN KEY (`meetid`) REFERENCES `Meetings` (`meetid`) ON DELETE CASCADE CONSTRAINT `participants_ibfk_2` CHECK (status IN ('a','d','u')) CONSTRAINT `participants_ibfk_3` CHECK (pid IN (SELECT name FROM Rooms) OR pid IN (SELECT userid FROM People)) ); I want to have a foreign key

Turn off constraints temporarily (MS SQL)

江枫思渺然 提交于 2019-12-17 02:26:22
问题 I'm looking for a way to temporarily turn off all DB's constraints (eg table relationships). I need to copy (using INSERTs) one DB's tables to another DB. I know I can achieve that by executing commands in proper order (to not break relationships). But it would be easier if I could turn off checking constraints temporarily and turn it back on after the operation's finish. Is this possible? 回答1: You can disable FK and CHECK constraints only in SQL 2005+ . See ALTER TABLE ALTER TABLE foo