Showing posts with label character. Show all posts
Showing posts with label character. Show all posts

Saturday, February 25, 2012

Removing character from varchar

Hello all,
How would you remove the last character from the following string:
jmy0084t?
Thanks
JonJon wrote:
> Hello all,
> How would you remove the last character from the following string:
> jmy0084t?
> Thanks
> Jon
>
select left('jmy0084t',len('jmy0084t')-1)|||Hi
Such as
DECLARE @.str varchar(10)
SET @.str = 'jmy0084t?'
SELECT @.str,LEFT(@.str,LEN(@.str)-1),STUFF(@.str,LEN(@.str),1,'')
John
"Jon" wrote:
> Hello all,
> How would you remove the last character from the following string:
> jmy0084t?
> Thanks
> Jon
>

Monday, February 20, 2012

Removing all end of line character from a string

Hello all,

Im looking for an efficient way to remove all end of line character from a string.

Is there a function to do that or to replace them with another character?

This should help you out:

declare @.string varchar(100),

@.CrLf varchar(2)

set @.String = 'line

with a break'

print @.string

set @.CrLf = char(13) + char(10) -- carriage return + line feed

set @.string = replace(@.string, @.CrLf, '')

print @.string

regards Gert-Jan