|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Want to know all the datatypes, lengths and the tables of col in aHi 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. 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 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. |
|||||||||||||||||||||||