charindex failure - SQL Server 2008 bug?

  • I do not know if this will work for you but if you change the datatype of your text_value column in the query to non unicode the correct values are returned.

    create table #tmp(id int, text_value ntext)

    insert into #tmp

    values(75,N'3456:Jones, Mark:976521'),

    (42,N'7654:Smith, John:23456'),

    (98,N'876:'Ðiên, Biêx:34567')

    select

    id

    , text_value

    , datalength(text_value) FieldLength

    , charindex(':', cast(text_value as varchar(50))) Colon1Pos

    , charindex(':', cast(text_value as varchar(50)), charindex(':', cast(text_value as varchar(50))) + 1) Colon2Pos

    from #tmp mv where id in (75, 42, 98)

    drop table #tmp

    idtext_value FieldLengthColon1PosColon2Pos

    753456:Jones, Mark:97652146 5 17

    427654:Smith, John:2345644 5 17

    98876:'Ðiên, Biêx:3456742 4 16

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • Very Nice! Thanks!

Viewing 2 posts - 1 through 3 (of 3 total)

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