Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find the field with the largest number of characters

Status
Not open for further replies.

impulse24

IS-IT--Management
Joined
Jul 13, 2001
Messages
167
Location
US
Hi,

I have all my data stored in a SQL Database. There are four different fields, all with the field lengths set to 255, varchar fields. What is the select statment I would use to find the field that is using the largest number of characters? I would like to resize the field lengths, but there is already data existing in the table, so I want to find the data using the longest characters. Please help..Thanks
 
SELECT MAX(DATALENGTH(field1)) FROM anyOldTable
 
worked like a charm..thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top