Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4326
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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