Replace String in Stored Proc

  • Try something like this:

    declare @line varchar(100)

    set @line = 'this is the first line' + char(13) + 'this is the second line'

    select @line

    -- replace line feed with space

    select replace (@line,char(13),' ')

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Generally thou when data is submitted with an enter in the string it is both the Carriage Return (13) and Line Feed (10) characters so you may want to do

    SET @line = replace(replace(@line, char(13),''), char(10), '<br>')

    to get it properly replaced in the string.

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

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