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,158 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
6 Comments
 
LVL 24

Expert Comment

by:Joe Woodhouse
Comment Utility
"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
Comment Utility
Error: Function 'chr' not found.
0
 

Expert Comment

by:TahirKhalil
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 24

Accepted Solution

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

Author Closing Comment

by:villavej
Comment Utility
Thanks, it's working now.
0
 

Expert Comment

by:dougsur
Comment Utility
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now