Text Fields Manipulation
Posted in 1997
Topics: Data Types & Schema Design
Hi all, I want to do some processing on a Text field in a Sybase table. Unfortunately the text field is greater than 255 chars. I am using readtext to access the Text field and I get a text pointer in return. The Sybase manual state that I can use the convert function to convert from a text pointer to a varchar type and that the conversion is limited to 255 char. The problem is that the convert function is returning nothing. I included a sample code to illustrate the problem. Any help would be appreciated. regards Sam create table #temp (id char (10), txtField text null) insert #temp values('1','Hello there line 1') insert #temp values('2','Hello there line 2') insert #temp values('3','Hello there line 3') insert #temp values('4','Hello there line 4') declare @SpaceLoc int declare @Word varchar(50) declare @vCharText varchar(230) declare @pText varbinary(16) /* get a text pointer to the Text field */ select @pText=textptr(txtField) from #temp where id='1' readtext #temp.txtField @pText 0 18 /* convert to varchar */ select @vCharText = convert(varchar(10), @pText) /* Get the first 5 char */ Select @Word = substring(@vCharText, 1, 5) drop table #temp