I want to store tables metadata into other table.So how to get all constraint and its type like whether it primary , unique or foreign key in MS SQL server.
table_name constraint_name constraint_type
user pk_user_id PRIMARY_KEY
user_role fk_role FOREIGN_KEY
user unique_email UNIQUE_KEY
USE INFORMATION_SCHEMA.TABLE_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_NAME='tablename'