Results 1 to 2 of 2

Thread: query problem

  1. #1
    Join Date
    Jul 2003
    Posts
    11

    Unanswered: query problem

    We have a table 'Testing' having with one of the fields as txt_acct_oper_instrs1 char(255) null

    A sample value of the data in the field is "ABCD$$$$NMKUY$$JUKL$ANH$ $$ adfd"

    In our stored procedure while selecting this field, we want to replace all the instances of character '$' by '#' . The position and number of '$' in the data varies from record to record. Is there a system procedure/function which we can use to achieve the above?

    Regards,

  2. #2
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    declare @x varchar(100),
    @y char(1),
    @z char(1)


    select @x = 'ABCD$$$$NMKUY$$JUKL$ANH$ $$ adfd',
    @y = '$',
    @z = '#'

    while charindex(@y, @x) <> 0
    select @x=stuff(@x,
    charindex(@y, @x),
    datalength(@z),
    @z)


    select @x

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •