If you need to find the longest string in a column in a table in SQL Server
which has a datatype of
X is a valid
integer value for the datatype, then you will need to use the following query:
select MyVarcharColumnName from MyTableName where len(MyVarcharColumnName) = (select max(len(MyVarcharColumnName)) from MyTableName)
In the query above you will need to substitute
MyTableName by your respective column and table names.
Update: [2013-05-18] fixed the code above as suggested by Andy in the comments