It is very commmon when a table have one or more to wide columns.
Sometimes developers choose not supported columns, for example, text type in MS SQL database.
I always looking for text, ntext, varchar(max) and nvarchar(max) :
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SELECT TABLE_CATALOG,TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, -- ORDINAL_POSITION, IS_NULLABLE,DATA_TYPE, CHARACTER_SET_NAME, COLLATION_NAME ,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE= 'text' or DATA_TYPE='ntext' or (DATA_TYPE='varchar' and CHARACTER_MAXIMUM_LENGTH =-1) or (DATA_TYPE='nvarchar' and CHARACTER_MAXIMUM_LENGTH =-1) order by TABLE_NAME,DATA_TYPE -- and TABLE_NAME ='table |
After it, I check the (n)varchar and (n)char columns.
I am finding the longest string.
1 2 3 4 5 6 7 |
-- varchar type SELECT max(len(oszlopnev)) from table_name -- SELECT max(datalength(code)) from table_name --you can see nvarchar use the double size --text type: SELECT max(datalength([oszlopnev])) FROM [tablename] |