Constraint Names and System Catalog Entries : sysconstraints « System Tables Views « SQL Server / T-SQL Tutorial

SQL Server / T-SQL Tutorial
1. Query
2. Insert Delete Update
3. Table
4. Table Join
5. Data Types
6. Set Operations
7. Constraints
8. Subquery
9. Aggregate Functions
10. Date Functions
11. Math Functions
12. String Functions
13. Data Convert Functions
14. Analytical Functions
15. Sequence Indentity
16. View
17. Index
18. Cursor
19. Database
20. Transact SQL
21. Procedure Function
22. Trigger
23. Transaction
24. XML
25. System Functions
26. System Settings
27. System Tables Views
28. User Role
29. CLR
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » System Tables Views » sysconstraints 
27. 26. 2. Constraint Names and System Catalog Entries
5CREATE TABLE customer
6(
7> cust_id      int         IDENTITY  NOT NULL  PRIMARY KEY,
8> cust_name    varchar(30NOT NULL
9)
10> GO
1>
2SELECT
3>     OBJECT_NAME(constid'Constraint Name',
4>     constid 'Constraint ID',
5>     CASE (status & 0xF)
6>         WHEN THEN 'Primary Key'
7>         WHEN THEN 'Unique'
8>         WHEN THEN 'Foreign Key'
9>         WHEN THEN 'Check'
10>         WHEN THEN 'Default'
11>         ELSE 'Undefined'
12>     END 'Constraint Type',
13>     CASE (status & 0x30)
14>         WHEN 0x10 THEN 'Column'
15>         WHEN 0x20 THEN 'Table'
16>         ELSE 'NA'
17>     END 'Level'
18FROM sysconstraints
19WHERE id=OBJECT_ID('customer')
20>
21> drop table customer;
22> GO
Constraint Name                                                                                                                  Constraint ID Constraint Type Level
-------------------------------------------------------------------------------------------------------------------------------- ------------- --------------- ------
PK__customer__43A1D464                                                                                                              1134679140 Primary Key     Table

(rows affected)
1>
27. 26. sysconstraints
27. 26. 1. The system table sysconstraints contains one row for every integrity constraint that is defined for a database object using the CREATE TABLE or ALTER TABLE statement.
27. 26. 2. Constraint Names and System Catalog Entries
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.