SQL Server : SQL Query to get schema of columns in a SQL table
You can use system table information_schema.COLUMNS to fetch schema details of a SQL table
Example
select *
FROM information_schema.COLUMNS WHERE table_name = 'employee' -- Table Name
ORDER BY ordinal_position
Column Names returned using above query :
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
COLUMN_NAME
ORDINAL_POSITION
COLUMN_DEFAULT
IS_NULLABLE
DATA_TYPE
CHARACTER_MAXIMUM_LENGTH
CHARACTER_OCTET_LENGTH
NUMERIC_PRECISION
NUMERIC_PRECISION_RADIX
NUMERIC_SCALE
DATETIME_PRECISION
CHARACTER_SET_CATALOG
CHARACTER_SET_SCHEMA
CHARACTER_SET_NAME
COLLATION_CATALOG
COLLATION_SCHEMA
COLLATION_NAME
DOMAIN_CATALOG
DOMAIN_SCHEMA
DOMAIN_NAME
No comments:
Post a Comment