Results 1 to 5 of 5

Thread: get max field length [Resolved]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    get max field length [Resolved]

    Is there a way to get the width of the longest value in a particular field? I'm spilling all the contents of a table out onto a web page and I want to make the fields wide enough to handle the biggest value in that particular field.

    DB: SQL Server 2000
    Language: PHP
    Last edited by ober0330; May 19th, 2004 at 12:00 PM.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Code:
    SELECT *
    FROM Information_Schema.Columns
    WHERE TABLE_NAME = 'TableName'
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    That returns the maximum allowed. I'm looking for the actual max length existing in the column.

    Example: Column x is a nvarchar field that can hold something 75 characters long. The longest actual entry is only 47 characters long. I want the 47 value.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016
    Code:
    Select Max(Len(x))
    From TableA
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  5. #5

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Perfect!
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width