sql >> Databasteknik >  >> RDS >> Sqlserver

Hur kan jag kontrollera om en SQL Server-begränsning finns?

 SELECT
    * 
    FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS 

annars prova detta

  SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT' 

eller

IF EXISTS(SELECT 1 FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'dbo.TableName'))
 BEGIN 
ALTER TABLE TableName DROP CONSTRAINT CONSTRAINTNAME 
END 


  1. En tabell finns fortfarande när den släpps

  2. Hur kan jag hitta sql-serverns portnummer från Windows-registret?

  3. Undvikande enstaka citat i JDBC med MySql

  4. MySQL Som flera värden