Forcing a Linefeed in SQL

Forcing a Linefeed in SQL

How do I force a linefeed character using SQL? I created a report (see below) but when I e-mailed this report from Unix the carriage return was not interpreted correctly.

I want the results to look like the following:

Invoice Number: 123456
Order Number: 444422222
Customer Number: abc123

When I e-mail this file using elm (to Microsoft Outlook or cc:Mail), I get the following :

Invoice Number: 123456 Order Number:44422222 Customer Number: abc123

The line break is not recognized. Any thoughts??

Here’s the code:

set verify offset echo offset feedback offset linesize 30set space 0set heading offcolumn invoice_num format  fold_after 1column sales_ord_num format  fold_after 1column rapid_txn_id format  fold_after 1column launch_dt format  fold_after 1column inv_dt format  fold_after 1spool &1select  'Invoice Number    :  &1' invoice_num,        'Sales Order Number:  ', sales_ord_num,        'RAPID Txn Number  :  ',  oh.mepr rapid_txn_id,        'Order Date        :  ', to_char(oh.timestamp,'MM/DD/YY') launch_dt,        'Ship Date         :  ', to_char(inv_dt,'MM/DD/YY') inv_dtfrom    sales_ord so, inv_hdr inv, ord_hdr ohwhere   so.sales_ord_id = inv.sales_ord_id

Hm, this looks like Oraclese… đŸ™‚

I don’t know if this will work, but you might try sending a carriage return and line feed combination?like CHAR(10)+CHAR(13)?at the end of each column name. That may do it for you.

See also  Who are the Modern GPU Cloud Providers?

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist