Thursday, 3 May 2012

SQL Column Names

I wanted to ensure that all my DB columns had been defined consistently.

Ray gave me this simple query to run on INFORMATION_SCHEMA.COLUMNS:

SELECT
   TABLE_NAME,
   COLUMN_NAME,
   DATA_TYPE,
   CHARACTER_MAXIMUM_LENGTH,
   NUMERIC_PRECISION,
   NUMERIC_SCALE,
   CHARACTER_SET_NAME
FROM
   INFORMATION_SCHEMA.COLUMNS
ORDER BY
   COLUMN_NAME

No comments: