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,191 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
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sparc Solaris hangs without crash dump & no events from messages 3 80
how to check for shares on aix 1 80
help pulling data string using Awk 9 70
Write an app 10 70
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…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

772 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