how can I deal with character of hard return?

Hi there,

Can anybody tell me how the character of hard return expressed in SQL Server. For example if I wanna convert any hard return character in a varchar field to something else, like a space, how could I write Replace function Or if I wanna search any hard return character, how could I write where clause

thanks a lot




Answer this question

how can I deal with character of hard return?

  • Jain2005

    select char(15)+char(12)as x into #temp1

    declare @x varchar(2) --search argument
    declare @y varchar(1)   --- value to be replaced
    select @y=char(12)

    select @x='%'+Char(12)+'%'

    select x from #temp1 where x like @x

    SELECT REPLACE(x,@y,'hello world')from #temp1



  • Danny Crowell

    thanks a lot for your reply.

    a silly question, what are CR and LF standing for



  • beckerben

    CR - carriage return
    LF - line feed


  • victorashi

    You can use char(13) for CR and char(10) for LF. So you can do:
    replace( @value, char(13), space(1) )
    where col like 'test' + char(13) + '%'


  • how can I deal with character of hard return?