substring more than 4000 characters

  • i have a data which has 8500 characters and i need the characters from 20 to 8350. how to do?

    substring returns only 4000 characters.

    please help

  • select substring(column_name,20,8340) from table_name

    is the above one is not working for you ?

    Thanks,

    Chandru

  • This is what I use, except it's for text data types. I thought that varchar (if that's what your field is set as) is a max lenght of 4000. Anyway, here's my script to output text that is more than 4000 characters.

    Declare @ptr varbinary(16),

    @length int,

    @Search varchar(200)

    Set@Search = 'Title: 29aa58348'

    --Set@Search = 'Title: 29aa58348'

    Select @length = DataLength(FODocument)

    From Admin..PrintJob

    Where DocumentName = @Search

    Select @ptr = TextPtr(FODocument)

    From Admin..PrintJob

    Where DocumentName = @Search

    --Select @Search As [SearchParameter], @length As [LengthOfField], @ptr As [PointLocation]

    If @ptr IS NOT NULL

    ReadText PrintJob.FODocument @ptr 0 @length

  • instead of going for varbinary or something you can use varchar(max).

    Just try out that.

    Thanks,

    Chandru

  • You can use the substring function with text data, so you will not have to deal with text pointers. The only thing is that instead of specifying the offset as the start and length characters, it needs to be specified in bytes.

    http://msdn.microsoft.com/en-us/library/ms187748(SQL.90).aspx

    Joie Andrew
    "Since 1982"

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply