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 |
thorv
Starting Member
7 Posts |
Posted - 2006-11-13 : 16:35:45
|
If I use this select it will select the first 8000 characters:select CAST(note AS varchar(8000)) from notesBut I need to select the last 8000 characters.I have done this for many years ago I think, but I don't remember.Someone that know this ?Thor |
|
X002548
Not Just a Number
15586 Posts |
|
Kristen
Test
22859 Posts |
Posted - 2006-11-13 : 17:04:30
|
Can't you just use SUBSTRING and DATALENGTH?SELECT SUBSTRING(MyText, DATALENGTH(MyText)-8000, 8000)noting that if MyText is Nvarchar then DATALENGTH is returning Bytes not CharactersKristen |
 |
|
thorv
Starting Member
7 Posts |
Posted - 2006-11-13 : 17:56:02
|
SELECT SUBSTRING(MyText, DATALENGTH(MyText)-8000, 8000) from mydatagives me this error:Expression result length exceeds the maximum. 8000 max, 16000 found???? :-) |
 |
|
Kristen
Test
22859 Posts |
Posted - 2006-11-13 : 18:16:58
|
Could be that SUBSTRING on TEXT won't go past first 8,000 characters, but I read BoL carefully [kinda expecting that] but it makes no mention of any limitations.If your MyText column is Nvarchar then you may need to count differently, because I think substring counts in Characters and DataLength in bytes.Kristen |
 |
|
thorv
Starting Member
7 Posts |
Posted - 2006-12-14 : 18:47:31
|
The problem was NTEXT, changed it to TEXT, then your SQL sample works great :-)Thanks !!Thor |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-12-14 : 19:57:11
|
you can likely still use an ntext column if you pick the last 4000 chars instead. http://www.elsasoft.org |
 |
|
|
|
|
|
|