Results 1 to 2 of 2

Thread: select replace

  1. #1
    Join Date
    Jan 2004
    Posts
    26

    Question Unanswered: select replace

    Hello,

    Creating an insert / update trigger that will copy a field formatted 1^2^3

    I want to replace ^ with , so I know I can use

    select replace (column, '^', ',')

    but my preferred format would be:

    1, 2 3

    I can not think how I can so this with a select statement

    Any help would be greatly appreciated!

    Cheers

  2. #2
    Join Date
    Feb 2004
    Location
    Bangalore, India
    Posts
    250
    Declare @v Varchar(max),
    @b Varchar(100)
    Select @v = Replace ('1^2^3^4^5^6^7^8^9^0^', '^', ' ')


    Select @b = Replace(Substring(@v,1,CharIndex(' ',@v) + 1),' ', ',')
    Select Replace(@v,Substring(@v,1,CharIndex(' ',@v) + 1),@b)
    Last edited by baburajv; 12-14-09 at 04:43. Reason: Correction
    Cheers....

    baburajv

Posting Permissions

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