Daniel Allen Langdon Daniel Allen Langdon - 1 year ago 72
SQL Question

How to get the size of a varchar[n] field in one SQL statement?

Suppose that I have a SQL table that has a varchar[1000] field called "Remarks".

I would like to craft a single SQL statement, which when executed, will return 1000, or whatever the size of the varchar field might be changed to in the future.

Something like

SELECT size(Remarks) FROM mytable

How do I do this?

Answer Source
select column_name, data_type, character_maximum_length    
  from information_schema.columns  
 where table_name = 'myTable'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download