Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to find the table on the basis of column lengh

Author  Topic 

goodman2253
Yak Posting Veteran

88 Posts

Posted - 2012-03-22 : 15:10:51
Hi All

Is it possible to find the table on the basis of column length
Example I want to find the tables in which the maximum length that column can have is 12

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-22 : 15:14:01
make use of INFORMATION_SCHEMA.COLUMNS view

SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE MAXIMUM_CHARACTER_LENGTH =12

will list all tables with columns having length as 12

didnt understand the reason for this though!

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

goodman2253
Yak Posting Veteran

88 Posts

Posted - 2012-03-23 : 23:26:27
It shows the following error
Msg 207, Level 16, State 1, Line 1
Invalid column name 'MAXIMUM_CHARACTER_LENGTH'.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-24 : 01:48:01
it should be



SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE CHARACTER_MAXIMUM_LENGTH=12 


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -