MSSQL · according to constraints_ Table name query constraint_ Table name

Time:2021-7-27
Reading time |0.13 minutes word count |214.4 characters
primary coverage |1. Introduction & background
MSSQL · according to constraints_ Table name query constraint_ Table name
Author | SCscHero Writing time | 2021/7/13 PM11:10
Article type |Series Degree of completion |Completed
motto Every great cause has a trivial beginning.

1、 Introduction & background    Completion: 100%


a) Coping with problems & scenarios

How to query table names according to constraints in MSSQL?
How to query constraints according to table names in MSSQL?

b) Solution principle & method

--Query table name according to constraints
SELECT TABLE_NAME ,
       COLUMN_NAME ,
       CONSTRAINT_NAME 
FROM   INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE  CONSTRAINT_NAME LIKE '%PK_DC_SYS_QuotaYearTem%'



--Query constraints by table name
SELECT TABLE_NAME ,
       COLUMN_NAME ,
       CONSTRAINT_NAME 
FROM   INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE  TABLE_NAME LIKE '%%'

c) Effect display

MSSQL · according to constraints_ Table name query constraint_ Table name

2、 Statements and references    Completion: 100%


Original blog post, please do not reprint without permission.

If you are helpful, you are welcome to like, collect and pay attention. If you have any questions, please comment! If you need to contact the blogger, you can write scschero directly.

Recommended Today

VBS obtains the operating system and its version number

VBS obtains the operating system and its version number ? 1 2 3 4 5 6 7 8 9 10 11 12 ‘************************************** ‘*by r05e ‘* operating system and its version number ‘************************************** strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _  & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _  (“Select * from […]