• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4374
  • Last Modified:

In T-SQL Sybase, how will you replace linefeed, chr(10), with space while querying from a table column?

select replace(<column name>,chr(10),'') from dbo.<table name>

The query above does not work, "Incorrect syntax near keyword, 'replace'

I'm unable to import the row because the column data contains line feed.
0
villavej
Asked:
villavej
1 Solution
 
Joe WoodhousePrincipal ConsultantCommented:
"replace" is a reserved word in Sybase T-SQL. Try exactly the same syntax, just call it str_replace instead:

     select str_replace(<column name>,chr(10),'') from dbo.<table name>
0
 
villavejAuthor Commented:
Error: Function 'chr' not found.
0
 
TahirKhalilCommented:
Assuming you have only 1 linefeed per value, you can use stuff+charindex as replace function:

declare @x char(35)
select @x="Test"+char(10)+"String"
select stuff(@x,charindex(char(10),@x),1,'*')

0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Joe WoodhousePrincipal ConsultantCommented:
Oh, I didn't even notice the "chr". Yeah. Make that "char(10)". 8-)
0
 
villavejAuthor Commented:
Thanks, it's working now.
0
 
dougsurCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now