How to see the contents of the checksum

Is there a TSQL script that will allow me to see the contents of the constraint. I found a question regarding Oracle, but I need a TSQL script.

How to see contents of check of restrictions on Oracle

I am aware of sys.check_constraints, however the "definition" returns null for all objects.

Select * from sys.check_constraints
+5
source share
4 answers

Another way

for verification restrictions

select definition,name
 from sys.check_constraints

for default restrictions

select definition,name
 from sys.default_constraints

and another way

 SELECT object_definition(OBJECT_ID(CONSTRAINT_NAME)),* 
 FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
 where CONSTRAINT_TYPE <> 'PRIMARY KEY'
+12
source
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
+2
source

sys.default_constraints

sys.check_constraints

sys.key_constraints (, )

sys.foreign_keys

sys.check_constraints to check constraints on columns that are invalid for validation constraints on tables. For instance:CONSTRAINT CK_NumeroUsadas_NumeroTotal CHECK (NumeroUsadas <= NumeroTotal AND NumeroTotal >= 0),

Search for text within a constraint:

1.) SELECT CONSTRAINT_NAME,CHECK_CLAUSE FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS WHERE CHECK_CLAUSE like '%NumeroTotal%' or CHECK_CLAUSE LIKE '%NumeroUsadas%'

2.) SELECT object_definition(OBJECT_ID(CONSTRAINT_NAME)),* FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'CHECK' AND object_definition(OBJECT_ID(CONSTRAINT_NAME)) like '%NumeroTotal%' or object_definition(OBJECT_ID(CONSTRAINT_NAME)) LIKE '%NumeroUsadas%'

+1
source

To have any validation restrictions, you will need objects of this type.

select *
from sys.objects
where sys.objects.type = 'C'

check_constraints

0
source

All Articles