HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to display MS SQL results vertically?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqlverticallyhowresultsdisplay

Problem

Here is what I've got currently when executing queries in sqlcmd:

1> SELECT 1,2,3,4
2> GO

----------- ----------- ----------- -----------
          1           2           3           4

(1 rows affected)


Although in case of longer results this output format is not human-readable, as it gets wrapped in the terminal.

How do I display the results vertically (an equivalent of \G in mysql)? Or in another way which can be human-readable?

Solution

The expected result when you use SELECT F1, F2, F2 is to obtain one column for each field in the SELECT sentence.

SELECT '1' + CHAR(13) + '2' + CHAR(13) + '3' + CHAR(13)

------
1
2
3

(1 row(s) affected)

Code Snippets

SELECT '1' + CHAR(13) + '2' + CHAR(13) + '3' + CHAR(13)

------
1
2
3


(1 row(s) affected)

Context

StackExchange Database Administrators Q#197407, answer score: 5

Revisions (0)

No revisions yet.