Solved

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

Posted on 2008-06-16
6
4,218 Views
Last Modified: 2013-12-27
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
Comment
Question by:villavej
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 24

Expert Comment

by:Joe Woodhouse
ID: 21794213
"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
 

Author Comment

by:villavej
ID: 21794241
Error: Function 'chr' not found.
0
 

Expert Comment

by:TahirKhalil
ID: 21794255
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
Independent Software Vendors: 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!

 
LVL 24

Accepted Solution

by:
Joe Woodhouse earned 250 total points
ID: 21794372
Oh, I didn't even notice the "chr". Yeah. Make that "char(10)". 8-)
0
 

Author Closing Comment

by:villavej
ID: 31467605
Thanks, it's working now.
0
 

Expert Comment

by:dougsur
ID: 22723544
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question