Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    4

    Unanswered: replace T-SQL fonction

    I would like to know how to use a replace fonction on a table
    Like, currently, the syntax for replace is

    SELECT REPLACE('abcdefghicde','cde','xxx')

    but I would like to do something more like

    SELECT REPLACE ((SELECT * FROM TABLE1) , 'cde', 'xxx')

    Thanks to reply!

  2. #2
    Join Date
    Oct 2003
    Posts
    4

    Re: replace T-SQL fonction

    I've found my problem ... which was in fact simple

    it's:

    select replace (FieldName , 'abc' , 'xxx') from MyTable...

    the problem was that my FieldName was a Text field... which doesn't work... you need a varchar or nvarchar there...
    so:

    select replace (CAST(FieldName AS varchar(8000)), 'abc', 'xxx') from myTable

    Thanks anyway!

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You should consider changing your fieldtype to VARCHAR if TEXT is not required. It will make coding easier and improve efficiency.

    blindman

Posting Permissions

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