How do I investigate the code that created the table? This is for the purpose of finding out if a column in a table contains aggregate information of other columns or is a column found somewhere else.
Asked
Active
Viewed 110 times
-4
-
Try `exec sp_columns OwallabyTable`. [[related question](http://stackoverflow.com/questions/319354/what-is-the-equivalent-of-describe-table-in-sql-server)] – Cam Aug 30 '16 at 14:17
1 Answers
0
if you wanted to find out the table information use the below scripts..
SELECT ORDINAL_POSITION, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
, IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableName'
SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE
WHERE TABLE_NAME = 'TableName'
SELECT name, type_desc, is_unique, is_primary_key
FROM sys.indexes
WHERE [object_id] = OBJECT_ID('dbo.TableName')

Unnikrishnan R
- 4,965
- 1
- 12
- 21