villavej
asked on
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.
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.
ASKER
Error: Function 'chr' not found.
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,'* ')
declare @x char(35)
select @x="Test"+char(10)+"String
select stuff(@x,charindex(char(10
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, it's working now.
the docs for sybase str_replace() can be found at
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc36271_1251/html/blocks/CJAEFCEG.htm
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc36271_1251/html/blocks/CJAEFCEG.htm
select str_replace(<column name>,chr(10),'') from dbo.<table name>