In high pressure professional environment, we sometime require to know which tables have some xyz column, and its quite tedious to search entire database. Here is the magic-wand query for this problem:
SELECT * FROM sys.tables WHERE object_id IN
(SELECT object_id FROM sys.columns WHERE name LIKE '%<column-name>%')
Amazing... isn't it! :)
Showing posts with label table. Show all posts
Showing posts with label table. Show all posts
Thursday, November 25, 2010
Wednesday, November 24, 2010
[T-SQL] Table Constraints
Table constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing data integrity.
Types of Constraints:
Types of Constraints:
- NOT NULL enforces not to accept NULL values
- UNIQUE assures that the data is unique in the column (including one NULL).
- PRIMARY KEY uniquely identifies each record in the table without allowing NULL.
- FOREIGN KEY constraints the data to be inserted that is available in table's column it points to.
- CHECK is used to limit the value range that can be placed in that column.
- DEFAULT is used to insert a default value to all new records, if no value is specified.
Subscribe to:
Posts (Atom)