on 04-07-2014 1:06 PM
Hi All
I am trying to replace a string with carriage return. How to use the carriage return in sap hana queries ?
eg,,
select 'firstname'||Char(13)||'lastname' from dummy;
I am expecting the result as
firstname
lastname
But the above query only results in firstnamelastname.
Please let me know how to include a new line (Carriage return) inside a string?
Regards
Suman
Hi Suman,
I don't know if it's still relevant but I had a similar requirement where I needed to concatenate some texts, separate them by CRLF and store the result in a table. This is how it was done:
DECLARE v_crlf NVARCHAR(2); | |
SELECT BINTOSTR( HEXTOBIN('0D0A') ) --Carriage return line feed INTO v_crlf FROM DUMMY; |
:v_crlf can now be used in select statements and logic to concatenate texts
Kind regards,
Rudy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to remove the carriage returns using REPLACE_REGEXPR in this example:
DO
BEGIN
DECLARE var1 NVARCHAR(20);
var1 := 'This is a
test';
SELECT
:var1
FROM
DUMMY
UNION ALL
SELECT
REPLACE_REGEXPR('\n' IN :var1 with '' occurrence all)
FROM
DUMMY;
END
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.