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 |
|
yyiiyyii2
Starting Member
5 Posts |
Posted - 2007-09-14 : 22:54:55
|
| How do u find the Max Length a description stored in a ntext column.Select Max(Len(ColumnName)) from SomeTable Does not work on ntext columns |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-14 : 22:55:39
|
| Use DATALENGTH instead of LEN? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-14 : 22:58:28
|
| Note that it provides an answer in BYTES not CHARACTERS, so divide by two for your Ntext.Note also that LEN will EXCLUDE trailing spaces from its result, whereas DATALENGTH will include them ...Kristen |
 |
|
|
yyiiyyii2
Starting Member
5 Posts |
Posted - 2007-09-15 : 19:04:36
|
| There seems to be a problem with that if there is a carriage return in the data. when i ranSelect Max(DataLength(ColumnName)) from SomeTable it return something around 2000 for a value. When i checked that row there was only 200 chars there including space |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-16 : 03:38:07
|
| The function won't be confused by any characters in the column, however your display routine might!So if, for example, your data contains one, or maybe several, CHAR(0) values they won't show up at all on display.If you have a specific row that you can easily test I think it would be worth checking the binary values of that row.SELECT CONVERT(varbinary(8000), CONVERT(varchar(8000), MyColumn))FROM MyTableWHERE MyPK = 'xxx'Kristen |
 |
|
|
|
|
|