May 2, 2005 at 4:02 pm
Hi. Can someone tell me how I could get the longest actual field length in a table. For example, say I have a NAME field in a table. I want to see the row that has the longest value in that NAME field in that table.
Juanita
May 2, 2005 at 8:58 pm
SELECT
MAX(LEN([Name]))
FROM
******************
Dinakar Nethi
Life is short. Enjoy it.
******************
May 3, 2005 at 4:22 am
To retrieve the entire row which has longest name:
SELECT *
FROM YourTable YT
WHERE LEN(YT.Column_1) = (SELECT MAX(LEN(Column_1)) FROM YourTable)
It will display all matching rows, if several rows have the same length of Column_1 entry. Should you need only one row each time, you have to limit it with SELECT TOP 1 *.
HTH, Vladan
May 3, 2005 at 5:31 am
Thanks so much !!! Both options work great. Exactly what I needed!!!
Juanita
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply