record that has the largest amount of data

  • What statement can I use against a table (longdescription) to find the record that has the most data in a particular field. (ldtext)

     

    Thanks for your time.

  • Hi Joan,

    Try this one:

    SELECT TOP 1
      DATALENGTH(ldtext), *
    FROM
      longtescription
    WHERE
      ldtext IS NOT NULL
    ORDER BY
      DATALENGTH(ldtext) DESC
    

    The first column in the result set will contain the actual size of the data. NULL columns should be eliminated because DATALENGTH(NULL) returns NULL.

    Regards,

    Goce.

  • Thank you.  This is exactly what I needed.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply