Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-01 : 07:59:10
|
| John writes "How to get the count value of the longest field length in a specified column, or sorting the records in order of the longest field length. Thanks for your help, greaty appreciated" |
|
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2002-07-01 : 08:08:15
|
| Lookup DATALENGTH in BOLHere's an example:USE pubsGOSELECT length = DATALENGTH(pub_name), pub_nameFROM publishersORDER BY length DESC |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-07-01 : 08:11:48
|
| select max(len(name)) from customeras long as name is NOT a TEXT field....len doesn't work with TEXT fields.select len(rtrim(name)) from customerorder by len(rtrim(name)) descremember that blank spaces count as part of the length of a column, if the type is just CHAR and not VARCHAR....ergo the "rtim"HTH |
 |
|
|
|
|
|