Home All Groups Group Topic Archive Search About

Want to know all the datatypes, lengths and the tables of col in a

Author
26 Jan 2006 9:32 PM
MittyKom
Hi All

I want to know how a certain column called nameID is declared in several
tables in a database called DBA. I have noticed that this column has been
specified with different datatypes and lenght in the database. I want to know
the datatypes, lengths and the tables. Pls help. Thank you in advance.

Author
26 Jan 2006 9:45 PM
Anith Sen
Start by investgating the syscolumns system table or
INFORMATION_SCHEMA.COLUMNS view . You should get the list of all the tables
where the column is being used.

--
Anith
Author
26 Jan 2006 9:51 PM
Mark Williams
USE DBA
GO

select table_name, column_name, "Data Type" =
CASE
  WHEN data_type LIKE '%char' THEN data_type + '(' +
    CAST(character_maximum_length as varchar(4)) + ')'
  WHEN data_type = 'decimal' THEN 'decimal(' + CAST(numeric_precision AS
varchar(2)) + ',' +
    CAST(numeric_scale AS varchar(2)) + ')'
  ELSE data_type
END
from information_schema.columns
where column_name LIKE '%nameid%'

--

Show quote
"MittyKom" wrote:

> Hi All
>
> I want to know how a certain column called nameID is declared in several
> tables in a database called DBA. I have noticed that this column has been
> specified with different datatypes and lenght in the database. I want to know
> the datatypes, lengths and the tables. Pls help. Thank you in advance.

AddThis Social Bookmark Button