Page 1 of 1

How to get the min and max varchar field size in DB2 table?

Posted: Tue Dec 30, 2014 11:26 am
by LalitaForums
Hi All,

I have a VARCHAR column in a DB2 table. I'm trying to know the minimum and maximum size this varchar filed can store. I tried using the MIN and MAX function but they can only be used for the numeric data type. Is there any function with which I can find the length for varchar, please help.

Re: How to get the min and max varchar field size in DB2 tab

Posted: Tue Dec 30, 2014 11:08 pm
by Anuj Dhawan
Hi,

MIN/MAX should have worked for you, try this:

Code: Select all

SELECT  MIN(LENGTH(VARCHAR_COL_A)),MAX(LENGTH(VARCHAR_COL_A)) 
  FROM  TABLE_NAME

Re: How to get the min and max varchar field size in DB2 tab

Posted: Wed Jan 07, 2015 4:41 pm
by LalitaForums
Great thanks Anuj.

Re: How to get the min and max varchar field size in DB2 tab

Posted: Thu Jan 08, 2015 12:08 pm
by Anuj Dhawan
You're welcome! :)